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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f23;
  color: #e0e0e0;
  min-height: 100vh;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-container {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-container h1 {
  color: #ffd700;
  font-size: 28px;
  margin-bottom: 8px;
}

.subtitle {
  color: #888;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: #aaa;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  background: #0f0f23;
  color: #e0e0e0;
  font-size: 16px;
}

.form-group input:focus {
  outline: none;
  border-color: #ffd700;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #ffd700;
  color: #0f0f23;
  width: 100%;
}

.btn-primary:hover {
  background: #ffed4a;
}

.btn-primary:disabled {
  background: #666;
  cursor: not-allowed;
}

.btn-secondary {
  background: #2a2a4a;
  color: #e0e0e0;
}

.btn-secondary:hover {
  background: #3a3a5a;
}

.error-message {
  background: #4a1010;
  border: 1px solid #ff4444;
  color: #ff6666;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
}

.info-text {
  color: #aaa;
  margin-bottom: 20px;
  font-size: 14px;
}

/* Header */
header {
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a4a;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

header h1 {
  color: #ffd700;
  font-size: 22px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#status-text {
  font-size: 13px;
  color: #888;
}

/* Tabs */
.tabs {
  max-width: 1600px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #2a2a4a;
}

.tab {
  padding: 10px 24px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #888;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab:hover {
  color: #e0e0e0;
}

.tab.active {
  color: #4fc3f7;
  border-bottom-color: #4fc3f7;
  font-weight: 600;
}

.tab-content {
  display: none;
}

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

.tab-actions {
  max-width: 1600px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Portefølje-statistikk */
.portfolio-stats {
  max-width: 1600px;
  margin: 16px auto;
  padding: 0 24px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat-card {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 16px 24px;
  text-align: center;
  min-width: 140px;
  flex: 1;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #e0e0e0;
}

.stat-label {
  font-size: 0.8rem;
  color: #888;
  margin-top: 4px;
}

/* Status badges */
.status-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.owned {
  background: #1a3a1a;
  color: #66cc66;
}

.status-badge.sold {
  background: #3a2a1a;
  color: #ff9933;
}

/* Portefølje action-knapper */
.btn-action {
  padding: 4px 8px;
  font-size: 14px;
  background: transparent;
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
}

.btn-action:hover {
  background: #2a2a4a;
}

.actions-cell {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.value-age {
  display: block;
  font-size: 10px;
  color: #666;
}

.add-form textarea {
  width: 100%;
  padding: 8px 12px;
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}

.add-form textarea:focus {
  outline: none;
  border-color: #4fc3f7;
}

.add-form select {
  width: 100%;
  padding: 8px 12px;
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.9rem;
}

/* Skannefremdrift */
.scan-progress {
  max-width: 1600px;
  margin: 16px auto 0;
  padding: 16px 24px;
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
}

.scan-progress.hidden {
  display: none;
}

.scan-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.scan-progress-header #scan-progress-text {
  font-weight: 600;
  color: #4fc3f7;
}

.scan-progress-header #scan-progress-count {
  color: #888;
}

.scan-progress-bar {
  width: 100%;
  height: 8px;
  background: #2a2a4a;
  border-radius: 4px;
  overflow: hidden;
}

.scan-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4fc3f7, #00e676);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.scan-progress-detail {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #888;
}

/* Controls */
.controls {
  max-width: 1600px;
  margin: 20px auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

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

.filter-group label {
  font-size: 14px;
  color: #aaa;
  cursor: pointer;
}

.filter-group select,
.filter-group input[type="number"] {
  padding: 8px 12px;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 14px;
}

.stats {
  margin-left: auto;
  font-size: 13px;
  color: #888;
}

/* Table */
.table-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px 40px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #1a1a2e;
  border-radius: 8px;
}

thead th {
  background: #16213e;
  padding: 14px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #2a2a4a;
  white-space: nowrap;
}

#listings-table thead th,
#portfolio-table thead th {
  position: sticky;
  top: 64px;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#listings-table thead th:first-child,
#portfolio-table thead th:first-child {
  border-top-left-radius: 8px;
}

#listings-table thead th:last-child,
#portfolio-table thead th:last-child {
  border-top-right-radius: 8px;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #1f1f3a;
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:hover {
  background: #1f1f3a;
}

tbody tr.highlight {
  background: #1a2e1a;
  border-left: 4px solid #00cc44;
}

tbody tr.highlight:hover {
  background: #1f3a1f;
}

.listing-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: #2a2a4a;
}

.price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.price-finn {
  color: #4da6ff;
}

.price-external {
  color: #ffd700;
}

.price-pc {
  color: #ff8866;
  font-weight: 600;
}

a.price-pc {
  text-decoration: none;
  border-bottom: 1px dashed #ff8866;
}

a.price-pc:hover {
  color: #ffaa88;
}

.no-data-cell {
  color: #555;
  text-decoration: none;
}

a.no-data-cell:hover {
  color: #ff8866;
  text-decoration: underline;
}

.pc-status {
  margin-left: 12px;
  font-size: 13px;
  color: #999;
  font-style: italic;
}

.profit-positive {
  color: #00cc44;
  font-weight: 700;
}

.profit-negative {
  color: #ff4444;
}

.profit-neutral {
  color: #888;
}

.source-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  background: #2a2a4a;
}

.source-badge.ebay { background: #1a3a1a; color: #66cc66; }
.source-badge.etsy { background: #3a2a1a; color: #ff9933; }
.source-badge.cardmarket { background: #1a2a3a; color: #6699ff; }
.source-badge.tcgplayer { background: #2a1a3a; color: #cc66ff; }
.source-badge.pricecharting { background: #3a1a2a; color: #ff8866; }
.source-badge.pokemontcg { background: #2a3a2a; color: #99ddaa; }
.source-badge.mavin { background: #2a2a3a; color: #aabbff; }
.source-badge.point130 { background: #1a3a3a; color: #66cccc; }
.source-badge.psa { background: #3a3a1a; color: #cccc66; }
.source-badge.hobbydb { background: #3a2a3a; color: #cc99cc; }

.btn-compare {
  padding: 6px 12px;
  font-size: 12px;
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
}

.btn-compare:hover {
  background: #3a3a5a;
}

.btn-delete {
  padding: 4px 8px;
  font-size: 14px;
  background: transparent;
  border: 1px solid #5a2a2a;
  border-radius: 4px;
  color: #ff6666;
  cursor: pointer;
  margin-left: 6px;
}

.btn-delete:hover {
  background: #3a1a1a;
}

/* Legg til oppføring skjema */
.add-form .form-group {
  margin-bottom: 12px;
}

.add-form label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: #aaa;
}

.add-form input {
  width: 100%;
  padding: 8px 12px;
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.add-form input:focus {
  outline: none;
  border-color: #4fc3f7;
}

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

.add-form .form-row .form-group {
  flex: 1;
}

a {
  color: #4da6ff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.loading {
  text-align: center;
  color: #888;
  padding: 40px;
}

.no-data {
  text-align: center;
  color: #666;
  padding: 60px 20px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 32px;
  max-width: 900px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: #888;
  font-size: 28px;
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

.comparison-table {
  margin-top: 16px;
}

.comparison-table td {
  font-size: 13px;
}

/* ===== MOBILE CARD LAYOUT ===== */
.card-list {
  display: none;
}

.card-item {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.card-item.highlight {
  border-left: 4px solid #00cc44;
  background: #1a2e1a;
}

.card-header {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.card-header .listing-image {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-prices {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.card-price-item {
  text-align: center;
}

.card-price-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.card-price-value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

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

.card-links a, .card-links button {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 6px;
  font-weight: 500;
}

/* ===== RESPONSIVE: Tablets (768px) ===== */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: center;
  }

  header h1 {
    font-size: 20px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 0 16px;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group select {
    flex: 1;
  }

  .stats {
    margin-left: 0;
    text-align: center;
  }

  .table-container {
    padding: 0 16px 40px;
  }

  thead th, tbody td {
    padding: 10px 8px;
    font-size: 12px;
  }

  .listing-image {
    width: 40px;
    height: 40px;
  }

  .modal-content {
    padding: 20px;
  }

  .login-container {
    padding: 32px 24px;
  }
}

/* ===== RESPONSIVE: Mobile (480px) ===== */
@media (max-width: 480px) {
  header {
    padding: 12px 16px;
  }

  header h1 {
    font-size: 18px;
  }

  .header-actions {
    gap: 8px;
  }

  .header-actions .btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  #status-text {
    font-size: 11px;
    width: 100%;
    text-align: center;
    order: -1;
  }

  /* Hide table, show cards on mobile */
  .table-container {
    display: none;
  }

  .card-list {
    display: block;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 12px 40px;
  }

  .controls {
    padding: 0 12px;
  }

  .login-container {
    padding: 24px 20px;
    border-radius: 8px;
  }

  .login-container h1 {
    font-size: 24px;
  }

  .btn-primary {
    padding: 14px 24px;
    font-size: 16px;
  }

  .form-group input {
    padding: 14px 16px;
  }

  /* Modal responsive */
  .modal {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-content {
    border-radius: 12px 12px 0 0;
    max-height: 90vh;
    padding: 20px 16px;
  }

  .comparison-table thead {
    display: none;
  }

  .comparison-table tbody tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid #2a2a4a;
  }

  .comparison-table tbody td {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border: none;
    font-size: 13px;
  }

  .comparison-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #aaa;
    margin-right: 8px;
  }
}

/* ===== RESPONSIVE: Small phones (360px) ===== */
@media (max-width: 360px) {
  .card-prices {
    grid-template-columns: 1fr 1fr;
  }

  .login-container {
    padding: 20px 16px;
  }

  .login-container h1 {
    font-size: 20px;
  }
}
