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

:root {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --card: #1e1e1e;
  --accent: #2ecc71;
  --accent-hover: #27ae60;
  --text: #e0e0e0;
  --text2: #888;
  --border: #333;
  --danger: #e74c3c;
  --warning: #f39c12;
}

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

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

.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }

/* Header */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 20px;
  color: var(--accent);
  white-space: nowrap;
}

.search-box {
  flex: 1;
  max-width: 360px;
  min-width: 180px;
}

.search-box input {
  width: 100%;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

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

.btn {
  display: inline-block;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }

/* Main Table */
.table-wrap {
  overflow-x: auto;
  margin: 20px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table.seeds-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

table.seeds-table th {
  background: var(--bg2);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 10px;
  text-align: left;
   border-bottom: 2px solid var(--accent);
   white-space: nowrap;
}

table.seeds-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

table.seeds-table tr.seed-row {
  cursor: pointer;
  transition: background 0.15s;
}

table.seeds-table tr.seed-row:hover {
  background: var(--card);
}

table.seeds-table tr.seed-row.expanded {
  background: var(--card);
}

table.seeds-table .seed-name {
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

table.seeds-table .seed-name img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

table.seeds-table .thumb-img {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
}

table.seeds-table .expand-icon {
  font-size: 10px;
  color: var(--text2);
  margin-left: 4px;
  transition: transform 0.2s;
}

.move-btn {
  cursor: pointer;
  color: var(--text2);
  font-size: 9px;
  padding: 1px 2px;
  opacity: 0.3;
  transition: opacity 0.15s;
  user-select: none;
  line-height: 1;
}
.move-btn:hover {
  opacity: 1;
  color: var(--accent);
}

tr.seed-row.expanded .expand-icon {
  transform: rotate(90deg);
}

.seed-row .badge-custom {
  display: inline-block;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--warning);
  color: #000;
  font-weight: 600;
  margin-left: 6px;
}

/* Expandable detail row */
tr.detail-row td {
  padding: 0;
  border: none;
}

.detail-panel {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 24px 30px;
}

.detail-panel-inner {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
}

.detail-panel img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.detail-panel .desc-section {
  margin-bottom: 20px;
}

.detail-panel .desc-section h3 {
  color: var(--accent);
  font-size: 14px;
  margin-bottom: 6px;
}

.detail-panel .desc-section p {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.7;
}

.detail-panel .source-link {
  font-size: 12px;
  color: var(--accent);
  display: inline-block;
  margin-bottom: 16px;
}

/* Journal section inside detail panel */
.journal-section {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.journal-section h3 {
  color: var(--accent);
  font-size: 16px;
  margin-bottom: 16px;
}

/* Timeline compact */
.timeline-compact {
  position: relative;
  padding-left: 24px;
}

.timeline-compact::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.tl-item {
  position: relative;
  margin-bottom: 12px;
  background: var(--card);
  border-radius: 6px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

.tl-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg2);
}

.tl-item .tl-date { font-size: 11px; color: var(--text2); }
.tl-item .tl-stage { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 10px; background: var(--accent); color: #000; font-weight: 600; margin: 2px 0 4px; }
.tl-item h5 { font-size: 13px; margin-bottom: 3px; }
.tl-item p { font-size: 12px; color: var(--text2); line-height: 1.5; }
.tl-item .tl-meta { font-size: 11px; color: var(--text2); margin-top: 4px; }
.tl-item .tl-del { float: right; background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; padding: 0 4px; }

.empty-journal {
  text-align: center;
  padding: 20px;
  color: var(--text2);
  font-size: 13px;
}

/* Entry form */
.entry-form { background: var(--card); border-radius: 8px; padding: 16px; border: 1px solid var(--border); margin-bottom: 16px; }
.entry-form h4 { color: var(--accent); font-size: 13px; margin-bottom: 10px; }
.entry-form .fr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.entry-form .fg { margin-bottom: 8px; }
.entry-form .fg label { display: block; font-size: 11px; color: var(--text2); margin-bottom: 3px; }
.entry-form .fg input, .entry-form .fg select, .entry-form .fg textarea {
  width: 100%; padding: 6px 10px; border-radius: 5px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 12px; outline: none; font-family: inherit;
}
.entry-form .fg textarea { min-height: 50px; resize: vertical; }
.entry-form .fg input:focus, .entry-form .fg select:focus, .entry-form .fg textarea:focus { border-color: var(--accent); }

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

.modal {
  background: var(--bg2);
  border-radius: 14px;
  padding: 28px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal h2 { color: var(--accent); font-size: 18px; margin-bottom: 16px; }
.modal-close { float: right; background: none; border: none; color: var(--text2); font-size: 22px; cursor: pointer; }
.modal-close:hover { color: var(--text); }

.modal .fg { margin-bottom: 12px; }
.modal .fg label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.modal .fg input, .modal .fg select, .modal .fg textarea {
  width: 100%; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; outline: none; font-family: inherit;
}
.modal .fg textarea { min-height: 60px; resize: vertical; }
.modal .fg input:focus, .modal .fg select:focus, .modal .fg textarea:focus { border-color: var(--accent); }
.modal .fr { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Login overlay */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-overlay.hidden {
  display: none;
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px 32px;
  width: 340px;
  max-width: 90vw;
  text-align: center;
}
.login-box .login-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.login-box h2 {
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 8px;
}
.login-box p {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 20px;
}
.login-box input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  text-align: center;
}
.login-box input[type="password"]:focus {
  border-color: var(--accent);
}
.login-error {
  font-size: 12px;
  color: #e74c3c;
  margin-top: 10px;
  display: none;
}

/* No results */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.no-results h2 { font-size: 20px; margin-bottom: 8px; }

.stats-bar {
  display: flex;
  gap: 20px;
  padding: 10px 0;
  font-size: 13px;
  color: var(--text2);
}

.stats-bar span strong { color: var(--accent); }

/* Footer */
footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 14px 0;
  margin-top: 32px;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-info {
  font-size: 12px;
  color: var(--text2);
}
.footer-actions {
  display: flex;
  gap: 8px;
}
.footer-actions .btn-sm {
  background: var(--card);
  color: var(--text2);
  border: 1px solid var(--border);
  font-size: 12px;
}
.footer-actions .btn-sm:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
  .detail-panel-inner { grid-template-columns: 1fr; }
  header .container { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 500px) {
  header .container { flex-direction: column; gap: 10px; }
  header h1 { font-size: 18px; text-align: center; }
  .search-box { min-width: 0; }
  header .btn-primary { width: 100%; text-align: center; }
}

@media (max-width: 700px) {
  table.seeds-table,
  table.seeds-table thead,
  table.seeds-table tbody,
  table.seeds-table tr,
  table.seeds-table td {
    display: block;
  }

  table.seeds-table {
    min-width: 0;
  }

  table.seeds-table thead {
    display: none;
  }

  table.seeds-table tr.seed-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
    padding: 10px 12px 12px;
    margin-bottom: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
  }

  table.seeds-table tr.seed-row.expanded {
    border-color: var(--accent);
  }

  table.seeds-table td {
    border: none !important;
    padding: 4px 0;
    font-size: 12px;
    background: none;
  }

  table.seeds-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 9px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1px;
  }

  /* Actions cell - full width top bar */
  table.seeds-table td.cell-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 0 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border) !important;
  }
  table.seeds-table td.cell-actions::before {
    display: none;
  }
  table.seeds-table td.cell-actions .expand-icon {
    margin-left: auto;
  }

  /* Seed name - full width */
  table.seeds-table td.seed-name {
    grid-column: 1 / -1;
    font-weight: 600;
    font-size: 14px;
    padding: 0 0 6px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border) !important;
  }
  table.seeds-table td.seed-name::before {
    display: none;
  }
  table.seeds-table td.seed-name img {
    display: none;
  }

  /* Detail row on mobile */
  tr.detail-row td {
    padding: 0 !important;
    border: none !important;
  }
  .detail-panel {
    padding: 16px;
    margin: -12px 0 12px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 10px 10px;
  }
  .detail-panel .detail-panel-inner {
    grid-template-columns: 1fr;
  }

  /* Modal on mobile */
  .modal { padding: 20px; margin: 10px; }
  .modal .fr { grid-template-columns: 1fr; }

  /* Stats bar */
  .stats-bar { font-size: 12px; gap: 12px; }
}

@media (max-width: 420px) {
  table.seeds-table tr.seed-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .detail-panel { padding: 12px; }
}
