/* PlexiOS v2 — Application Styles */

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--ps-font);
  font-size: var(--ps-text-base);
  color: var(--ps-text);
  background: var(--ps-bg);
  line-height: 1.5;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ps-accent-hover); text-decoration: none; }

/* === SHELL === */
.shell {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 56px); /* Odejmij topbar */
  max-width: var(--ps-max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* === TOP BAR (zunifikowany z inbox.html) === */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--ps-z-sticky);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  padding-top: calc(12px + var(--ps-safe-top));
  background: rgba(13, 17, 23, 0.72);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--ps-border);
  height: calc(56px + var(--ps-safe-top));
}
.topbar-left { display: flex; align-items: center; gap: 32px; }
.topbar-logo {
  font-family: var(--ps-font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ps-text);
  text-decoration: none;
  white-space: nowrap;
}
.topbar-logo span { color: var(--ps-accent); }

.topbar-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
.topbar-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--ps-radius-full);
  color: var(--ps-text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.18s;
  position: relative;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}
.topbar-nav-item:hover { background: var(--ps-glass); color: var(--ps-text); }
.topbar-nav-item.active {
  background: var(--ps-accent-glow);
  color: var(--ps-accent);
}
.topbar-nav-item .ic { font-size: 14px; opacity: 0.9; }
.topbar-nav-item .nav-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ps-error);
  box-shadow: 0 0 6px var(--ps-error);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}
.topbar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--ps-radius-full);
  background: linear-gradient(135deg, var(--ps-accent), var(--ps-accent-2, var(--ps-info)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--ps-text-inverse);
  font-family: var(--ps-font-display);
}
.topbar-logout {
  background: none;
  border: none;
  color: var(--ps-text-dim);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.18s;
}
.topbar-logout:hover { color: var(--ps-error); background: var(--ps-glass); }

@media (max-width: 720px) {
  .topbar-nav-item span:not(.ic) { display: none; }
  .topbar-nav-item { padding: 7px 10px; }
  .topbar-logo { font-size: 0.95rem; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar-left { gap: 16px; }
}

/* === QUICK TOOLS CARDS === */
.quick-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--ps-space-3);
  margin-bottom: var(--ps-space-6);
}
.tool-card {
  display: flex;
  align-items: center;
  gap: var(--ps-space-3);
  padding: var(--ps-space-4);
  background: var(--ps-glass);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.tool-card:hover {
  border-color: var(--ps-accent);
  background: var(--ps-glass-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--ps-accent-glow);
}
.tool-icon {
  font-size: 28px;
  display: block;
}
.tool-title {
  font-family: var(--ps-font-display);
  font-weight: 600;
  font-size: var(--ps-text-md);
  margin-bottom: 2px;
}
.tool-sub {
  font-size: var(--ps-text-xs);
  color: var(--ps-text-muted);
}

/* === MODAL (Shipping calculator) === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: var(--ps-z-modal);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.modal-overlay.show { display: flex; }
.modal-box {
  width: min(580px, 92vw);
  background: rgba(20, 26, 35, 0.96);
  backdrop-filter: blur(40px);
  border: 1px solid var(--ps-border-hover);
  border-radius: var(--ps-radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--ps-space-4) var(--ps-space-5);
  border-bottom: 1px solid var(--ps-border);
}
.modal-header h3 {
  font-family: var(--ps-font-display);
  font-size: var(--ps-text-lg);
}
.modal-body { padding: var(--ps-space-5); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--ps-space-3);
  margin-bottom: var(--ps-space-4);
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--ps-text-sm);
  color: var(--ps-text-muted);
}
.form-grid input, .form-grid select {
  background: var(--ps-glass);
  border: 1px solid var(--ps-border);
  color: var(--ps-text);
  padding: 10px 12px;
  border-radius: var(--ps-radius);
  font-family: inherit;
  font-size: var(--ps-text-sm);
}
.form-grid input:focus, .form-grid select:focus {
  outline: none;
  border-color: var(--ps-accent);
  box-shadow: 0 0 0 3px var(--ps-accent-glow);
}
.btn-primary {
  background: var(--ps-accent);
  color: var(--ps-text-inverse);
  border: none;
  padding: 12px 24px;
  border-radius: var(--ps-radius-full);
  font-family: var(--ps-font-display);
  font-weight: 600;
  font-size: var(--ps-text-sm);
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}
.btn-primary:hover {
  background: var(--ps-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--ps-accent-glow-strong);
}

.ship-results {
  margin-top: var(--ps-space-4);
}
.ship-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--ps-space-3);
  background: var(--ps-glass);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  margin-bottom: 6px;
}
.ship-result-row .courier {
  font-weight: 500;
}
.ship-result-row .delivery {
  font-size: var(--ps-text-xs);
  color: var(--ps-text-muted);
  margin-left: var(--ps-space-2);
}
.ship-result-row .price {
  font-family: var(--ps-font-display);
  font-weight: 700;
  color: var(--ps-accent);
  font-size: var(--ps-text-lg);
}
.ship-result-row.fallback { border-left: 3px solid var(--ps-warning); }
.ship-result-row.fallback .price::after {
  content: " ⚠";
  color: var(--ps-warning);
}

/* === HEADER === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ps-space-3) var(--ps-space-4);
  padding-top: calc(var(--ps-space-3) + var(--ps-safe-top));
  background: var(--ps-bg-subtle);
  border-bottom: 1px solid var(--ps-border);
  backdrop-filter: blur(var(--ps-glass-blur));
  position: sticky;
  top: 0;
  z-index: var(--ps-z-sticky);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--ps-space-2);
}

.header-logo h1 {
  font-family: var(--ps-font-display);
  font-size: var(--ps-text-lg);
  font-weight: 700;
  background: linear-gradient(135deg, var(--ps-accent) 0%, var(--ps-info) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-logo .version {
  font-size: var(--ps-text-xs);
  color: var(--ps-text-dim);
  padding: 2px 6px;
  background: var(--ps-glass);
  border-radius: var(--ps-radius-full);
  border: 1px solid var(--ps-border);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--ps-space-2);
}

.header-user {
  font-size: var(--ps-text-sm);
  color: var(--ps-text-muted);
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ps-success);
  animation: pulse 2s ease-in-out infinite;
}

.health-dot.error { background: var(--ps-error); }

/* === BOTTOM NAV === */
.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--ps-space-2) 0;
  padding-bottom: calc(var(--ps-space-2) + var(--ps-safe-bottom));
  background: var(--ps-bg-subtle);
  border-top: 1px solid var(--ps-border);
  backdrop-filter: blur(var(--ps-glass-blur));
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--ps-z-sticky);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--ps-space-1) var(--ps-space-3);
  color: var(--ps-text-dim);
  font-size: var(--ps-text-xs);
  cursor: pointer;
  transition: color var(--ps-duration) var(--ps-ease);
  border: none;
  background: none;
  position: relative;
}

.nav-item .icon { font-size: 20px; }
.nav-item.active { color: var(--ps-accent); }
.nav-item:hover { color: var(--ps-text); }

.nav-badge {
  position: absolute;
  top: 0;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--ps-radius-full);
  background: var(--ps-error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* === MAIN CONTENT === */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: var(--ps-safe-bottom);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* === VIEWS === */
.view { display: none; padding: var(--ps-space-4); }
.view.active { display: block; animation: fadeIn 0.3s var(--ps-ease); }

/* === DASHBOARD VIEW === */
.dashboard-greeting {
  margin-bottom: var(--ps-space-6);
}

.dashboard-greeting h2 {
  font-family: var(--ps-font-display);
  font-size: var(--ps-text-2xl);
  font-weight: 700;
  margin-bottom: var(--ps-space-1);
}

.dashboard-greeting p {
  color: var(--ps-text-muted);
  font-size: var(--ps-text-sm);
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--ps-space-3);
  margin-bottom: var(--ps-space-6);
}

.stat-card {
  background: var(--ps-glass);
  border: 1px solid var(--ps-glass-border);
  border-radius: var(--ps-radius-md);
  padding: var(--ps-space-4);
  text-align: center;
  backdrop-filter: blur(12px);
  transition: all var(--ps-duration) var(--ps-ease);
}

.stat-card:hover {
  background: var(--ps-glass-hover);
  border-color: var(--ps-border-hover);
  transform: translateY(-1px);
}

.stat-value {
  font-family: var(--ps-font-display);
  font-size: var(--ps-text-2xl);
  font-weight: 700;
}

.stat-value.green { color: var(--ps-success); }
.stat-value.yellow { color: var(--ps-warning); }
.stat-value.red { color: var(--ps-error); }
.stat-value.blue { color: var(--ps-accent-hover); }

.stat-label {
  font-size: var(--ps-text-xs);
  color: var(--ps-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--ps-space-1);
}

/* Recent quotes list */
.section-title {
  font-family: var(--ps-font-display);
  font-size: var(--ps-text-md);
  font-weight: 600;
  margin-bottom: var(--ps-space-3);
  display: flex;
  align-items: center;
  gap: var(--ps-space-2);
}

.quote-card {
  background: var(--ps-glass);
  border: 1px solid var(--ps-glass-border);
  border-radius: var(--ps-radius-md);
  padding: var(--ps-space-4);
  margin-bottom: var(--ps-space-3);
  cursor: pointer;
  transition: all var(--ps-duration) var(--ps-ease);
}

.quote-card:hover {
  background: var(--ps-glass-hover);
  border-color: var(--ps-accent-glow);
  box-shadow: 0 0 20px var(--ps-accent-glow);
}

.quote-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--ps-space-2);
}

.quote-client {
  font-weight: 600;
  font-size: var(--ps-text-md);
}

.quote-price {
  font-family: var(--ps-font-display);
  font-weight: 700;
  color: var(--ps-success);
}

.quote-subject {
  color: var(--ps-text-muted);
  font-size: var(--ps-text-sm);
  margin-bottom: var(--ps-space-2);
}

.quote-meta {
  display: flex;
  gap: var(--ps-space-3);
  font-size: var(--ps-text-xs);
  color: var(--ps-text-dim);
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--ps-radius-full);
  font-size: var(--ps-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-draft { background: rgba(113, 113, 122, 0.2); color: var(--ps-text-muted); }
.badge-sent { background: var(--ps-accent-glow); color: var(--ps-accent-hover); }
.badge-accepted { background: rgba(34, 197, 94, 0.15); color: var(--ps-success); }
.badge-rejected { background: rgba(239, 68, 68, 0.15); color: var(--ps-error); }
.badge-new { background: rgba(245, 158, 11, 0.15); color: var(--ps-warning); }
.badge-production { background: rgba(6, 182, 212, 0.15); color: var(--ps-info); }

/* === CHAT VIEW === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 120px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--ps-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--ps-space-3);
  -webkit-overflow-scrolling: touch;
}

.chat-welcome {
  text-align: center;
  padding: var(--ps-space-12) var(--ps-space-4);
  color: var(--ps-text-muted);
}

.chat-welcome h3 {
  font-family: var(--ps-font-display);
  font-size: var(--ps-text-xl);
  color: var(--ps-text);
  margin-bottom: var(--ps-space-2);
}

.chat-welcome p {
  font-size: var(--ps-text-sm);
  margin-bottom: var(--ps-space-6);
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ps-space-2);
  justify-content: center;
}

.quick-prompt {
  padding: var(--ps-space-2) var(--ps-space-4);
  background: var(--ps-glass);
  border: 1px solid var(--ps-glass-border);
  border-radius: var(--ps-radius-full);
  color: var(--ps-text-muted);
  font-size: var(--ps-text-sm);
  cursor: pointer;
  transition: all var(--ps-duration) var(--ps-ease);
}

.quick-prompt:hover {
  background: var(--ps-accent-glow);
  border-color: var(--ps-accent);
  color: var(--ps-text);
}

/* Chat messages */
.msg {
  max-width: 85%;
  padding: var(--ps-space-3) var(--ps-space-4);
  border-radius: var(--ps-radius-lg);
  font-size: var(--ps-text-base);
  line-height: 1.6;
  animation: msgIn 0.3s var(--ps-ease);
}

.msg.user {
  align-self: flex-end;
  background: var(--ps-accent);
  color: #fff;
  border-bottom-right-radius: var(--ps-radius-sm);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--ps-bg-card);
  border: 1px solid var(--ps-border);
  border-bottom-left-radius: var(--ps-radius-sm);
}

.msg.assistant strong { color: var(--ps-accent-hover); }
.msg.assistant code {
  background: var(--ps-bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

.msg-meta {
  display: flex;
  gap: var(--ps-space-2);
  margin-top: var(--ps-space-1);
  font-size: var(--ps-text-xs);
  color: var(--ps-text-dim);
  opacity: 0.7;
}

.msg.user .msg-meta { color: rgba(255,255,255,0.6); }

/* Streaming indicator */
.typing {
  align-self: flex-start;
  padding: var(--ps-space-3);
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ps-text-dim);
  animation: bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

/* Chat input */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--ps-space-2);
  padding: var(--ps-space-3) var(--ps-space-4);
  background: var(--ps-bg-subtle);
  border-top: 1px solid var(--ps-border);
}

.chat-input {
  flex: 1;
  background: var(--ps-bg-card);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-md);
  padding: var(--ps-space-3) var(--ps-space-4);
  color: var(--ps-text);
  font-family: var(--ps-font);
  font-size: var(--ps-text-base);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color var(--ps-duration);
}

.chat-input:focus {
  border-color: var(--ps-accent);
  box-shadow: 0 0 0 2px var(--ps-accent-glow);
}

.chat-input::placeholder { color: var(--ps-text-dim); }

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ps-accent);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--ps-duration) var(--ps-ease);
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--ps-accent-hover);
  box-shadow: var(--ps-shadow-glow);
  transform: scale(1.05);
}

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

/* === QUOTE ACTIONS (after AI response) === */
.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ps-space-2);
  margin-top: var(--ps-space-3);
  padding-top: var(--ps-space-3);
  border-top: 1px solid var(--ps-border);
}

.action-btn {
  padding: var(--ps-space-2) var(--ps-space-4);
  border-radius: var(--ps-radius-full);
  font-size: var(--ps-text-sm);
  font-weight: 500;
  border: 1px solid var(--ps-border);
  background: var(--ps-glass);
  color: var(--ps-text);
  cursor: pointer;
  transition: all var(--ps-duration) var(--ps-ease);
}

.action-btn:hover {
  background: var(--ps-glass-hover);
  border-color: var(--ps-border-hover);
}

.action-btn.primary {
  background: var(--ps-accent);
  border-color: var(--ps-accent);
  color: #fff;
}

.action-btn.primary:hover {
  background: var(--ps-accent-hover);
  box-shadow: var(--ps-shadow-glow);
}

.action-btn.success {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--ps-success);
  color: var(--ps-success);
}

/* === HISTORY VIEW === */
.search-bar {
  display: flex;
  gap: var(--ps-space-2);
  margin-bottom: var(--ps-space-4);
}

.search-input {
  flex: 1;
  background: var(--ps-bg-card);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius-md);
  padding: var(--ps-space-3) var(--ps-space-4);
  color: var(--ps-text);
  font-family: var(--ps-font);
  font-size: var(--ps-text-base);
  outline: none;
}

.search-input:focus {
  border-color: var(--ps-accent);
}

.filter-btn {
  padding: var(--ps-space-2) var(--ps-space-3);
  background: var(--ps-glass);
  border: 1px solid var(--ps-border);
  border-radius: var(--ps-radius);
  color: var(--ps-text-muted);
  font-size: var(--ps-text-sm);
  cursor: pointer;
}

.filter-btn.active {
  background: var(--ps-accent-glow);
  border-color: var(--ps-accent);
  color: var(--ps-accent-hover);
}

/* === INBOX VIEW === */
.inbox-item {
  background: var(--ps-glass);
  border: 1px solid var(--ps-glass-border);
  border-radius: var(--ps-radius-md);
  padding: var(--ps-space-4);
  margin-bottom: var(--ps-space-3);
  transition: all var(--ps-duration) var(--ps-ease);
}

.inbox-item.needs-attention {
  border-left: 3px solid var(--ps-warning);
}

.inbox-item.auto-ready {
  border-left: 3px solid var(--ps-success);
}

.inbox-from {
  font-weight: 600;
  margin-bottom: var(--ps-space-1);
}

.inbox-subject {
  color: var(--ps-text-muted);
  font-size: var(--ps-text-sm);
}

.inbox-questions {
  margin-top: var(--ps-space-3);
  padding: var(--ps-space-3);
  background: rgba(245, 158, 11, 0.08);
  border-radius: var(--ps-radius);
  border: 1px solid rgba(245, 158, 11, 0.15);
}

.inbox-questions h4 {
  font-size: var(--ps-text-sm);
  color: var(--ps-warning);
  margin-bottom: var(--ps-space-2);
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
  position: fixed;
  top: calc(var(--ps-space-4) + var(--ps-safe-top));
  right: var(--ps-space-4);
  z-index: var(--ps-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--ps-space-2);
}

.toast {
  padding: var(--ps-space-3) var(--ps-space-4);
  border-radius: var(--ps-radius);
  font-size: var(--ps-text-sm);
  font-weight: 500;
  backdrop-filter: blur(var(--ps-glass-blur));
  box-shadow: var(--ps-shadow-md);
  animation: toastIn 0.3s var(--ps-ease);
  max-width: 320px;
}

.toast.success {
  background: rgba(34, 197, 94, 0.9);
  color: #fff;
}

.toast.error {
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
}

.toast.info {
  background: rgba(37, 99, 235, 0.9);
  color: #fff;
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: var(--ps-space-12);
  color: var(--ps-text-dim);
}

.empty-state .icon { font-size: 48px; margin-bottom: var(--ps-space-4); }
.empty-state p { font-size: var(--ps-text-sm); }

/* === LOADING === */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ps-space-8);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--ps-border);
  border-top-color: var(--ps-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

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

/* === PRISMATIC GLOW (feel the plexi) === */
.prismatic-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 300px;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(600px circle at 30% 10%, rgba(37, 99, 235, 0.08), transparent 60%),
    radial-gradient(400px circle at 70% 20%, rgba(6, 182, 212, 0.06), transparent 50%),
    radial-gradient(500px circle at 50% 5%, rgba(139, 92, 246, 0.05), transparent 55%);
  animation: prismaticShift 12s ease-in-out infinite alternate;
}

@keyframes prismaticShift {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ps-border);
  border-radius: var(--ps-radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--ps-border-hover); }

/* === SKELETON LOADING === */
.skeleton {
  background: linear-gradient(90deg, var(--ps-bg-card) 25%, var(--ps-bg-elevated) 50%, var(--ps-bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--ps-radius);
}

.skeleton-card {
  height: 80px;
  margin-bottom: var(--ps-space-3);
  border-radius: var(--ps-radius-md);
}

.skeleton-stat {
  height: 72px;
  border-radius: var(--ps-radius-md);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === ERROR BANNER === */
.error-banner {
  padding: var(--ps-space-3) var(--ps-space-4);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--ps-radius);
  color: var(--ps-error);
  font-size: var(--ps-text-sm);
  display: flex;
  align-items: center;
  gap: var(--ps-space-2);
  margin-bottom: var(--ps-space-4);
  animation: fadeIn 0.3s var(--ps-ease);
}

.error-banner button {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--ps-error);
  cursor: pointer;
  font-size: var(--ps-text-sm);
  text-decoration: underline;
}

/* === STAGGERED CARD ANIMATIONS === */
.quote-card { animation: cardIn 0.3s var(--ps-ease) both; }
.quote-card:nth-child(1) { animation-delay: 0s; }
.quote-card:nth-child(2) { animation-delay: 0.05s; }
.quote-card:nth-child(3) { animation-delay: 0.1s; }
.quote-card:nth-child(4) { animation-delay: 0.15s; }
.quote-card:nth-child(5) { animation-delay: 0.2s; }

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

.stat-card { animation: statIn 0.4s var(--ps-ease) both; }
.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.16s; }

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

/* === PULL TO REFRESH INDICATOR === */
.pull-indicator {
  text-align: center;
  padding: var(--ps-space-3);
  color: var(--ps-text-dim);
  font-size: var(--ps-text-sm);
  display: none;
}

.pull-indicator.active {
  display: block;
  animation: fadeIn 0.2s;
}

/* === QUOTE CARD POLISH === */
.quote-card {
  position: relative;
  overflow: hidden;
}

.quote-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--ps-accent);
  opacity: 0;
  transition: opacity var(--ps-duration);
}

.quote-card:hover::before { opacity: 1; }

/* === STATUS COLOR BARS === */
.quote-card[data-status="sent"]::before { background: var(--ps-accent); opacity: 1; }
.quote-card[data-status="accepted"]::before { background: var(--ps-success); opacity: 1; }
.quote-card[data-status="rejected"]::before { background: var(--ps-error); opacity: 1; }
.quote-card[data-status="production"]::before { background: var(--ps-info); opacity: 1; }

/* === CHAT ENHANCEMENTS === */
.msg.assistant {
  position: relative;
}

.msg.assistant::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 12px;
  width: 3px;
  height: calc(100% - 24px);
  background: linear-gradient(to bottom, var(--ps-accent), transparent);
  border-radius: 2px;
  opacity: 0.5;
}

/* === MOBILE ENHANCEMENTS === */
@media (max-width: 768px) {
  .chat-input-bar {
    padding-bottom: calc(var(--ps-space-3) + var(--ps-safe-bottom));
  }

  .quote-card { padding: var(--ps-space-3); }

  .stats-grid { gap: var(--ps-space-2); }

  .stat-card { padding: var(--ps-space-3); }
  .stat-value { font-size: var(--ps-text-xl); }

  .search-bar { position: sticky; top: 0; z-index: 10; background: var(--ps-bg); padding-bottom: var(--ps-space-2); }

  .action-btn { padding: var(--ps-space-2) var(--ps-space-3); font-size: var(--ps-text-xs); }
}

/* === OFFLINE INDICATOR === */
.offline-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--ps-space-2);
  background: var(--ps-warning);
  color: var(--ps-text-inverse);
  font-size: var(--ps-text-sm);
  font-weight: 600;
  text-align: center;
  z-index: var(--ps-z-toast);
  transform: translateY(-100%);
  transition: transform 0.3s var(--ps-ease);
}

.offline-bar.show { transform: translateY(0); }

/* === DETAIL VIEW POLISH === */
.detail-conversation {
  border-left: 2px solid var(--ps-border);
  padding-left: var(--ps-space-4);
  margin-top: var(--ps-space-4);
}

.detail-conversation .msg {
  max-width: 100%;
  margin-bottom: var(--ps-space-2);
}

/* === DESKTOP (>768px) === */
@media (min-width: 769px) {
  .shell { max-width: var(--ps-max-width); }

  .bottom-nav {
    max-width: var(--ps-max-width);
    left: 50%;
    transform: translateX(-50%);
  }

  .stats-grid { grid-template-columns: repeat(4, 1fr); }

  .chat-container { height: calc(100dvh - 140px); }

  .msg { max-width: 75%; }
}
