:root {
  --bg-dark: #0b0f19;
  --bg-sidebar: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #24344d;
  --border-color: #334155;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
}

/* =========================================
   PIN SCREEN & KEYPAD
   ========================================= */
.pin-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #1e293b 0%, #0b0f19 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 16px;
}

.pin-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  padding: 30px 24px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.pin-logo {
  display: inline-block;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.pin-card h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
}

.pin-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 18px;
}

.pin-dots .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--border-color);
  transition: all 0.2s ease;
}

.pin-dots .dot.filled {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.6);
  transform: scale(1.15);
}

.pin-error-text {
  min-height: 20px;
  font-size: 13px;
  color: var(--accent-rose);
  font-weight: 600;
  margin-bottom: 14px;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.key-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 14px 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.key-btn:active {
  background: var(--accent-cyan);
  color: #041014;
  transform: scale(0.96);
}

.key-btn.key-action {
  font-size: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* =========================================
   APP LAYOUT & RESPONSIVE STRUCTURE
   ========================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 320px;
  min-width: 320px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 20px;
  z-index: 100;
  height: 100vh;
  position: sticky;
  top: 0;
}

.brand-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
}

.brand .logo-badge {
  display: inline-block;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.brand h2 {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.brand .accent-text {
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand .tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--text-dim);
  padding: 0 8px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.session-item {
  padding: 12px 14px;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  word-break: break-word;
}

.session-item:hover {
  background: var(--bg-card);
  border-color: var(--border-color);
}

.session-item.active {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.4);
}

.session-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

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

.ai-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.status-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-emerald);
}

.status-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-lock-logout {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fecdd3;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* =========================================
   MOBILE HEADER
   ========================================= */
.mobile-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 90;
}

.menu-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}

.menu-toggle-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}

.mobile-brand-title {
  font-size: 17px;
  font-weight: 800;
}

.mobile-brand-title span {
  color: var(--accent-cyan);
}

.mobile-quick-scan-btn {
  background: var(--accent-emerald);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* =========================================
   MAIN CONTENT
   ========================================= */
.main-content {
  flex: 1;
  padding: 32px 36px;
  overflow-y: auto;
  max-width: 1400px;
  width: 100%;
  min-width: 0; /* Prevents flex child from overflowing */
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 20px;
  width: 100%;
}

.header-titles {
  min-width: 0;
  flex: 1;
}

.session-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.top-nav h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.header-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

/* STRATEGY BANNER */
.ai-strategy-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  width: 100%;
}

.strategy-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.strategy-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.badge-vram {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  width: 100%;
}

.strategy-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.strategy-item-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.strategy-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* CONTROLS BAR */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  width: 100%;
}

.filter-scrollable {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-chip {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--accent-cyan);
  color: #041014;
  border-color: var(--accent-cyan);
}

.filter-chip.chip-super.active {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #04140c;
}

.filter-chip.chip-good.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: #fff;
}

.filter-chip.chip-risk.active {
  background: var(--accent-rose);
  border-color: var(--accent-rose);
  color: #fff;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.switch-label input {
  accent-color: var(--accent-cyan);
  width: 16px;
  height: 16px;
}

.results-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.results-stats b {
  color: #fff;
}

.stats-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* OFFERS GRID */
.offers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  width: 100%;
}

.offer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow-sm);
}

.offer-card.deal-super {
  border-top: 3px solid var(--accent-emerald);
}

.offer-card.deal-good {
  border-top: 3px solid var(--accent-purple);
}

.offer-card.deal-risk {
  border-top: 3px solid var(--accent-rose);
  background: rgba(244, 63, 94, 0.03);
}

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

.platform-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.platform-allegro {
  color: #ff5a00;
  border: 1px solid rgba(255, 90, 0, 0.3);
}

.platform-olx {
  color: #002f34;
  background: #23e5db;
}

.platform-allegro_lokalnie {
  color: #ff9100;
  border: 1px solid rgba(255, 145, 0, 0.3);
}

.ai-score-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
}

.score-super {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.score-good {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.score-risk {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.offer-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.price-current {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-mono);
}

.price-estimated {
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: line-through;
}

.discount-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.discount-bad {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

.specs-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.spec-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.spec-pill.highlight-primary {
  border-color: rgba(6, 182, 212, 0.4);
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
}

.spec-pill.highlight-success {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
}

.spec-pill.highlight-purple {
  border-color: rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
}

.spec-pill.highlight-warning {
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.12);
}

.spec-pill.highlight-vram {
  border-color: rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.1);
}

.spec-pill.highlight-monitor {
  border-color: rgba(6, 182, 212, 0.4);
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.ai-verdict-box {
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.verdict-header {
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.verdict-text {
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

.pros-cons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.pro-item, .con-item {
  font-size: 11px;
  display: flex;
  gap: 6px;
  align-items: flex-start;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.pro-item { color: #a7f3d0; }
.con-item { color: #fecdd3; }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
}

.seller-location {
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #041014;
}

.btn-scanner {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #022013;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* MODALS */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.form-group {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

.form-group input, .form-group textarea {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  width: 100%;
}

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

.form-row .half {
  flex: 1;
}

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

.eval-result-box {
  margin-top: 14px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* =========================================
   MOBILE RESPONSIVENESS (< 860px)
   ========================================= */
@media (max-width: 860px) {
  .app-layout {
    flex-direction: column;
    width: 100%;
    overflow-x: hidden;
  }

  .mobile-header {
    display: flex;
    width: 100%;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    height: 100vh;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .mobile-close-btn {
    display: block;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 95;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .main-content {
    padding: 12px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .top-nav {
    flex-direction: column;
    gap: 14px;
  }

  .top-nav h1 {
    font-size: 19px;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .header-actions .btn {
    width: 100%;
  }

  .strategy-grid {
    grid-template-columns: 1fr;
  }

  .controls-bar {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-scrollable {
    overflow-x: auto;
    padding-bottom: 6px;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .filter-group {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .offers-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
  }

  .offer-card {
    padding: 14px;
  }

  .price-current {
    font-size: 20px;
  }
}
