* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #222;
  background: #f5f5f5;
}

/* Header */
header {
  background: #00a859;
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 20px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#account-info {
  font-size: 13px;
  opacity: 0.9;
}

/* Buttons */
.btn-primary {
  background: #00a859;
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary:hover {
  background: #008f4a;
}

.btn-secondary {
  background: white;
  color: #333;
  border: 1px solid #ddd;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #f0f0f0;
}

header .btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}

header .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-wide {
  width: 100%;
}

.hint {
  color: #999;
  font-size: 12px;
  margin-top: 6px;
}

.btn-danger {
  background: none;
  color: #cc3333;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 3px;
}

.btn-danger:hover {
  background: #ffeeee;
}

/* Login screen */
.login-box {
  max-width: 500px;
  margin: 80px auto;
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-box h2 {
  margin-bottom: 16px;
  color: #00a859;
}

.login-box p {
  margin-bottom: 20px;
  color: #666;
  line-height: 1.5;
}

.login-box hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid #eee;
}

.login-box details {
  text-align: left;
}

.login-box summary {
  cursor: pointer;
  color: #666;
  margin-bottom: 10px;
}

.login-form {
  text-align: left;
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  margin-bottom: 10px;
  font-weight: 500;
  color: #333;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  margin-top: 4px;
}

.login-form input:focus {
  outline: none;
  border-color: #00a859;
  box-shadow: 0 0 0 2px rgba(0, 168, 89, 0.15);
}

#btn-login-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
}

.login-error {
  background: #fff3f3;
  color: #cc3333;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 8px;
}

.login-status {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 8px;
}

.captcha-hint {
  color: #666;
  font-size: 13px;
  margin-bottom: 6px;
}

.login-box textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
  margin-bottom: 10px;
}

/* Subscriptions */
.subscriptions-section {
  background: white;
  margin: 16px 24px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.subscriptions-section h2 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #333;
}

.sub-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.sub-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.sub-form select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.sub-form input[type="number"] {
  width: 70px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
}

.interval-label {
  color: #888;
  font-size: 13px;
}

#subs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sub-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
}

.sub-chip .sub-query {
  font-weight: 600;
  color: #2e7d32;
}

.sub-chip .sub-meta {
  color: #666;
  font-size: 11px;
}

/* Items section */
.items-section {
  background: white;
  margin: 0 24px 24px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.items-header h2 {
  font-size: 16px;
  color: #333;
}

.items-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-link-input {
  width: 280px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
}

.badge {
  background: #FF4444;
  color: white;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  margin-left: 6px;
  font-weight: normal;
}

.badge.zero {
  background: #ccc;
}

/* Table */
#items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#items-table thead th {
  background: #fafafa;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #eee;
  white-space: nowrap;
  user-select: none;
}

#items-table thead th.sortable:hover {
  background: #f0f0f0;
  color: #333;
}

#items-table thead th.sortable::after {
  content: " \2195";
  opacity: 0.3;
  font-size: 12px;
}

#items-table thead th.sort-asc::after {
  content: " \2191";
  opacity: 0.8;
}

#items-table thead th.sort-desc::after {
  content: " \2193";
  opacity: 0.8;
}

#items-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}

#items-table tbody tr:hover {
  background: #f9f9f9;
}

#items-table tbody tr.unseen {
  border-left: 3px solid #00a859;
  background: #f0faf4;
}

#items-table tbody tr.unseen:hover {
  background: #e5f5ec;
}

@keyframes highlight-new {
  0% { background: #b9f6ca; }
  100% { background: #f0faf4; }
}

#items-table tbody tr.just-added {
  animation: highlight-new 1.5s ease-out;
}

#items-table tbody td {
  padding: 8px 10px;
  vertical-align: middle;
}

.col-time {
  width: 140px;
}

.col-query {
  width: 100px;
}

.col-title {
  min-width: 200px;
}

.col-price {
  width: 110px;
  text-align: right;
}

.col-location {
  width: 150px;
}

.col-link {
  width: 60px;
  text-align: center;
}

.col-offer {
  width: 70px;
  text-align: center;
}

.btn-offer {
  background: #1976d2;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-offer:hover {
  background: #1565c0;
}

/* Offer modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 650px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-width: 90%;
  max-height: 80vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  font-size: 15px;
  color: #333;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 16px 20px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #eee;
  text-align: right;
}

.offer-prices {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #555;
}

.offer-prices strong {
  color: #222;
}

#offer-message {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #f0fdf4;
}

.offer-brief {
  font-size: 13px;
  line-height: 1.5;
}

.offer-section {
  margin-bottom: 16px;
}

.offer-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: #1976d2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e3f2fd;
}

.offer-section p {
  color: #444;
  margin: 0;
}

.offer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 8px;
}

.offer-table th,
.offer-table td {
  padding: 6px 10px;
  border: 1px solid #e0e0e0;
  text-align: left;
}

.offer-table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #333;
}

.offer-table tr:nth-child(even) td {
  background: #fafafa;
}

.offer-table tr:last-child td {
  font-weight: 600;
  background: #f0f7ff;
}

.offer-raw {
  white-space: pre-wrap;
  font-size: 13px;
  color: #444;
}

.offer-loading {
  color: #888;
  text-align: center;
  padding: 40px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
}

.offer-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #e0e0e0;
  border-top-color: #1976d2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

td.price {
  text-align: right;
  font-weight: 500;
  white-space: nowrap;
}

td.price-byn {
  color: #00a859;
}

td a {
  color: #1976d2;
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

.query-tag {
  background: #e3f2fd;
  color: #1565c0;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  white-space: nowrap;
}

/* You Save column */
.col-save {
  width: 100px;
  text-align: right;
}

.ai-save-cell {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
  font-size: 13px;
}

.save-positive {
  color: #2e7d32;
}

.save-negative {
  color: #c62828;
}

/* AI Settings Section */
.ai-settings-section {
  background: white;
  margin: 0 24px 16px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ai-settings-section summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-settings-section summary h2 {
  font-size: 16px;
  color: #333;
  margin: 0;
}

.ai-settings-section h4 {
  margin-top: 16px;
  margin-bottom: 10px;
  color: #555;
  font-size: 14px;
}

.settings-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.settings-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #444;
  font-size: 13px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #00a859;
  box-shadow: 0 0 0 2px rgba(0, 168, 89, 0.15);
}

.form-group .help-text {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

.settings-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

/* Provider Quick Select */
.provider-quick-select {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.provider-quick-btn {
  flex: 1;
  min-width: 130px;
  padding: 14px 16px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}

.provider-quick-btn:hover {
  border-color: #bbb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.provider-quick-btn.active {
  border-color: #00a859;
  background: #f0faf4;
  box-shadow: 0 4px 12px rgba(0, 168, 89, 0.15);
}

.provider-quick-btn .provider-icon {
  font-size: 28px;
  display: block;
}

.provider-quick-btn span:not(.provider-icon) {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.provider-quick-btn small {
  font-size: 11px;
  color: #888;
  font-weight: normal;
}

/* Connection Status */
.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f5f5f5;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.connection-status .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
}

.connection-status.connected {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.connection-status.connected .status-dot {
  background: #10b981;
  animation: status-pulse 2s infinite;
}

.connection-status.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.connection-status.error .status-dot {
  background: #ef4444;
}

.connection-test-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* AI credits badge */
.ai-credits {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: 12px;
  color: #666;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
}
.ai-credits.low {
  color: #dc2626;
  background: #fef2f2;
  font-weight: 600;
}

/* Platform credits bar in settings */
.platform-credits-info {
  margin-top: 12px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
}
.credits-bar-label {
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
}

/* New credits card design */
.credits-card {
  margin-top: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 168, 89, 0.08);
}

.credits-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.credits-label {
  font-size: 13px;
  font-weight: 600;
  color: #166534;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.credits-count {
  font-size: 18px;
  font-weight: 700;
  color: #15803d;
}

.credits-count #backend-credits-used {
  color: #059669;
}

.credits-count #backend-credits-limit {
  color: #15803d;
}

.credits-bar-container {
  background: #d1fae5;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.credits-bar {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  border-radius: 5px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.5);
}

.credits-bar.warning {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.5);
}

.credits-bar.low {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.5);
}

.credits-remaining {
  font-size: 12px;
  color: #047857;
  font-weight: 500;
  text-align: right;
}

.credits-bar-fill {
  height: 100%;
  background: #22c55e;
  border-radius: 4px;
  transition: width 0.3s;
}
.credits-bar-fill.warning {
  background: #f59e0b;
}


/* Deal column */
.col-deal {
  width: 120px;
  text-align: center;
}

/* Estimated price column */
.col-est-price {
  width: 100px;
  text-align: right;
}

/* Verdict badges */
.verdict-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}

.verdict-great {
  background: #a5d6a7;
  color: #1b5e20;
  font-weight: 700;
}

.verdict-good {
  background: #c8e6c9;
  color: #1b5e20;
}

.verdict-fair {
  background: #fff9c4;
  color: #f57f17;
}

.verdict-slightly-bad {
  background: #ffe0b2;
  color: #e65100;
}

.verdict-bad {
  background: #ffcdd2;
  color: #b71c1c;
}

.verdict-suspicious {
  background: #f3e5f5;
  color: #6a1b9a;
}

.verdict-unclear {
  background: #e0e0e0;
  color: #616161;
}

.verdict-error {
  background: #ffebee;
  color: #c62828;
}

.verdict-na {
  background: #f5f5f5;
  color: #bbb;
}

/* Verdict spinner */
.verdict-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e0e0e0;
  border-top-color: #00a859;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* No items message */
#no-items {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

#no-items p {
  font-size: 14px;
}

/* Packages Modal */
.packages-modal .modal-box {
  width: 800px;
  max-width: 95%;
}

.packages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 4px;
}

.package-card {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.package-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.15);
  border-color: #059669;
}

.package-card.recommended {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #059669;
  border-width: 3px;
}

.package-card.recommended::before {
  content: "⭐ BEST VALUE";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #059669;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  letter-spacing: 0.5px;
}

.package-name {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.package-credits {
  font-size: 32px;
  font-weight: 800;
  color: #059669;
  margin: 12px 0;
}

.package-credits-label {
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.package-price {
  font-size: 20px;
  font-weight: 700;
  color: #334155;
  margin: 12px 0;
}

.package-price-byn {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 4px;
}

.package-savings {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  margin-top: 8px;
}

.package-description {
  font-size: 12px;
  color: #64748b;
  margin-top: 12px;
  line-height: 1.4;
}

.loading-spinner {
  text-align: center;
  padding: 40px;
  color: #94a3b8;
  font-size: 14px;
}

/* Low credits warning */
.credits-card.low-credits .credits-bar {
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.credits-card.no-credits .credits-bar {
  background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
}

.credits-card.low-credits {
  border-color: #fbbf24;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.credits-card.no-credits {
  border-color: #f87171;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}
