:root {
  --bg:      #0f1117;
  --bg2:     #1a1d27;
  --bg3:     #22263a;
  --border:  #2e3250;
  --text:    #e8eaf6;
  --text2:   #9094b8;
  --green:   #4caf50;
  --white-asp: #e0e0e0;
  --purple:  #9c27b0;
  --tip:     #ff9800;
  --accent:  #5c6bc0;
  --accent2: #7986cb;
  --card:    #1e2235;
  --shadow:  0 4px 24px rgba(0,0,0,0.4);
  --up:      #4caf50;
  --down:    #f44336;
}

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ── TICKER ── */
#ticker-bar {
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  height: 34px;
  overflow: hidden;
  display: flex;
  align-items: center;
}
#ticker-toggle {
  flex-shrink: 0;
  padding: 0 12px;
  cursor: pointer;
  color: var(--text2);
  font-size: 11px;
  border-right: 1px solid var(--border);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}
#ticker-track { overflow: hidden; flex: 1; height: 100%; display: flex; align-items: center; }
#ticker-inner {
  display: flex;
  white-space: nowrap;
  animation: ticker-scroll 80s linear infinite;
}
#ticker-bar.paused #ticker-inner { animation-play-state: paused; }
.ticker-item {
  padding: 0 20px;
  font-size: 12px;
  color: var(--text2);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ticker-item .variety-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.ticker-item .price { color: var(--text); font-weight: 600; }
@keyframes ticker-scroll { 0%{transform:translateX(0)} 100%{transform:translateX(-50%)} }

/* ── NEWS TICKER ── */
#news-ticker-bar {
  background: #0d1117;
  border-bottom: 1px solid var(--border);
  height: 28px;
  overflow: hidden;
  display: flex;
  align-items: center;
}
#news-ticker-track { overflow: hidden; flex: 1; height: 100%; display: flex; align-items: center; }
#news-ticker-inner {
  display: flex;
  white-space: nowrap;
  animation: news-ticker-scroll 382s linear infinite;
}
.news-ticker-item {
  padding: 0 18px;
  font-size: 11px;
  color: #9094b8;
  text-decoration: none;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  height: 28px;
  transition: color 0.2s;
}
.news-ticker-item:hover { color: #fff; }
.news-ticker-sep {
  padding: 0 14px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: transparent;
  height: 28px;
  display: flex;
  align-items: center;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  text-shadow: 0 0 6px #e53935, 0 0 12px #e53935;
  animation: news-sep-glow 2s ease-in-out infinite;
}
@keyframes news-sep-glow {
  0%,100% { text-shadow: 0 0 4px #e53935, 0 0 10px #e53935; color: #ff6b6b; }
  50%      { text-shadow: 0 0 10px #ff1744, 0 0 22px #ff1744, 0 0 35px #ff1744; color: #fff; }
}
@keyframes news-ticker-scroll { 0%{transform:translateX(-50%)} 100%{transform:translateX(0)} }

/* ── HEADER ── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.logo span { color: var(--green); }
.header-center { flex: 1; text-align: center; }
.last-update { font-size: 11px; color: var(--text2); }
.lang-selector { display: flex; gap: 4px; }
.lang-btn {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s;
}
.lang-btn.active, .lang-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── MAIN ── */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

/* ── SECTION ── */
.price-section {}
.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.section-header h2 { font-size: 16px; font-weight: 700; }
.section-sub { font-size: 11px; color: var(--text2); }

/* ── TABLE ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}
.matrix-table th {
  background: var(--bg2);
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.matrix-table th.col-variety { text-align: right; min-width: 110px; }
.matrix-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.matrix-table tr:last-child td { border-bottom: none; }
.matrix-table tr:hover td { background: var(--bg3); cursor: pointer; }

.col-country { min-width: 180px; }
.country-flag { font-size: 16px; margin-right: 6px; }
.country-flag-img { width: 20px; height: 15px; margin-right: 6px; vertical-align: middle; border-radius: 2px; object-fit: cover; }

/* Variety header accent */
.green-h  { color: #4caf50 !important; }
.white-h  { color: #e0e0e0 !important; }
.purple-h { color: #9c27b0 !important; }
.tip-h    { color: #ff9800 !important; }

/* Price cells */
.price-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.price-val {
  font-weight: 700;
  font-size: 13px;
}
.price-val.no-data { color: var(--text2); font-weight: 400; font-size: 12px; }
.price-date { display: block; font-size: 10px; color: var(--text2); margin-top: 1px; }

/* ── POPUP ── */
#popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#popup-overlay.open { display: flex; }
#popup {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 500px;
  max-width: 95vw;
  box-shadow: var(--shadow);
  position: relative;
}
#popup-close {
  position: absolute; top: 16px; right: 16px;
  background: transparent; border: none; color: var(--text2); cursor: pointer; font-size: 18px;
}
#popup h2 { font-size: 16px; margin-bottom: 4px; }
#popup .popup-meta { color: var(--text2); font-size: 12px; margin-bottom: 12px; }
#popup .popup-price { font-size: 22px; font-weight: 700; margin-bottom: 12px; display: flex; gap: 24px; flex-wrap: wrap; }
#popup .popup-source { font-size: 11px; color: var(--text2); word-break: break-all; }
#popup .popup-source a { color: var(--accent2); text-decoration: none; }
#popup .popup-source a:hover { text-decoration: underline; }

/* ── ADMIN BAR ── */
#admin-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 100;
}
.admin-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.admin-btn:hover { background: var(--accent); border-color: var(--accent); }
.admin-btn.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
#scrape-status { font-size: 11px; color: var(--text2); margin-left: 8px; }

/* ── OVERRIDE FORM ── */
#override-form {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  position: fixed;
  bottom: 60px; right: 24px;
  width: 320px;
  z-index: 900;
  box-shadow: var(--shadow);
}
#override-form.open { display: block; }
#override-form h3 { margin-bottom: 14px; font-size: 14px; }
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 4px; }
.form-row input, .form-row select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 13px;
}
.form-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn-save { flex:1; background:var(--accent); border:none; border-radius:6px; color:#fff; padding:8px; cursor:pointer; font-weight:600; }
.btn-cancel { background:transparent; border:1px solid var(--border); border-radius:6px; color:var(--text2); padding:8px 14px; cursor:pointer; }

/* ── MISC ── */
.loading { color: var(--text2); text-align: center; padding: 32px; font-size: 13px; }
.dot-pulse::after { content: '...'; animation: dots 1.5s infinite; }
@keyframes dots { 0%,20%{content:'.'} 40%{content:'..'} 60%,100%{content:'...'} }
main { padding-bottom: 60px; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── LAYOUT ── */
main {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 20px;
}
#main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 32px; }

/* ── NEWS PANEL ── */
#news-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 8px;
  max-height: calc(100vh - 80px);
  overflow: hidden;
}
.news-panel-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.news-panel-header h3 { font-size: 13px; font-weight: 700; }
.news-sub { font-size: 10px; color: var(--text2); }
#news-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.news-loading { color: var(--text2); font-size: 11px; padding: 12px 14px; }
.news-item-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.news-item-top a { flex: 1; }
.news-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  opacity: 0;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  transition: opacity 0.15s;
}
.news-item:hover .news-del-btn { opacity: 1; }
.news-del-btn:hover { filter: sepia(1) saturate(5) hue-rotate(310deg); }
.news-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--bg3); }
.news-item a {
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  display: block;
  margin-bottom: 4px;
}
.news-item a:hover { color: var(--accent2); }
.news-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.news-source { font-size: 10px; color: var(--accent2); font-weight: 600; }
.news-date   { font-size: 10px; color: var(--text2); }
.news-lang   { font-size: 9px; color: var(--text2); background: var(--bg3); padding: 1px 4px; border-radius: 3px; }
.news-summary { font-size: 11px; color: var(--text2); line-height: 1.4; }
.news-add-source {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.news-add-source input, .news-add-source select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 11px;
}
.news-add-source button {
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: #fff;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  width: 100%;
}
.news-add-source button:hover { background: var(--accent2); }
#ns-status { font-size: 10px; color: var(--text2); min-height: 14px; }

/* ── GROWERS PANEL ── */
#growers-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 8px;
  max-height: calc(100vh - 80px);
  overflow: hidden;
}
.growers-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.growers-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.growers-title-row h3 { font-size: 13px; font-weight: 700; }
.grower-add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}
.grower-add-btn:hover { background: var(--accent2); }
.growers-filters { display: flex; flex-direction: column; gap: 5px; }
.growers-filters input,
.growers-filters select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 11px;
  width: 100%;
  box-sizing: border-box;
}
#growers-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
}
.grower-card {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
}
.grower-card:last-child { border-bottom: none; }
.grower-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2px;
}
.grower-actions { display: flex; gap: 4px; }
.grower-edit-btn, .grower-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  opacity: 0.35;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}
.grower-card:hover .grower-edit-btn,
.grower-card:hover .grower-del-btn { opacity: 1; }
.grower-del-btn:hover { filter: sepia(1) saturate(5) hue-rotate(310deg); }
.grower-name {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.grower-meta { color: var(--text2); font-size: 10px; margin-bottom: 3px; }
.grower-field { color: var(--text2); font-size: 10px; }
.grower-field a { color: var(--accent); text-decoration: none; }
.grower-field a:hover { text-decoration: underline; }
.grower-no-contact { font-style: italic; opacity: 0.4; }
.grower-empty { padding: 16px 12px; color: var(--text2); font-size: 11px; text-align: center; }

/* ── ADD GROWER OVERLAY ── */
#add-grower-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
#add-grower-overlay.open { display: flex; }
.add-grower-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
  width: min(400px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
}
.add-grower-modal h3 { margin: 0 0 14px; font-size: 15px; }
.add-grower-modal label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 8px;
  gap: 3px;
}
.add-grower-modal input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
}
.ag-hint { font-size: 10px; color: var(--text2); margin: 4px 0 8px; }
.ag-error { font-size: 11px; color: #e53935; min-height: 14px; margin: 0 0 8px; }
.ag-actions { display: flex; gap: 8px; }
.ag-actions .btn-save { flex: 1; }
.ag-actions .btn-cancel { flex: 1; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  #news-panel { width: 100%; position: static; max-height: 400px; }
  #growers-panel { width: 100%; position: static; max-height: 400px; }
}

/* ── NEWS TRANSLATION TOOLTIP ── */
#news-translate-tip {
  display: none;
  position: fixed;
  z-index: 1200;
  width: 260px;
  background: #12152a;
  border: 1px solid #5c6bc0;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
  pointer-events: none;
}
#news-translate-tip.visible { display: block; }
.ntt-label {
  font-size: 10px;
  color: #7986cb;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.ntt-text {
  font-size: 12px;
  color: #e8eaf6;
  line-height: 1.5;
}

/* ── PRICE HOVER TOOLTIP ── */
#price-tooltip {
  display: none;
  position: fixed;
  z-index: 1100;
  width: 296px;
  background: #1a1d2e;
  border: 1px solid #3a3f5c;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.65);
  overflow: hidden;
  pointer-events: auto;
}
#price-tooltip.visible { display: block; }
.pt-header {
  padding: 10px 12px 8px;
  font-weight: 700;
  font-size: 13px;
  color: #e8eaf6;
  border-bottom: 1px solid #2e3250;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-screenshot-wrap {
  height: 140px;
  background: #0f1117;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#pt-screenshot {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pt-rows {
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pt-row {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  line-height: 1.4;
}
.pt-icon { flex-shrink: 0; width: 16px; text-align: center; font-size: 11px; margin-top: 1px; }
#pt-url {
  color: #7986cb;
  text-decoration: none;
  word-break: break-all;
  font-size: 11px;
}
#pt-url:hover { text-decoration: underline; }
.pt-row span:not(.pt-icon) { color: #c5c8e8; font-size: 11px; }

@media (max-width: 700px) {
  main { padding: 12px; }
  .matrix-table th, .matrix-table td { padding: 6px 8px; font-size: 12px; }
}
