:root {
  --bg: #0a0a0a;
  --surface: #161618;
  --surface-2: #1f1f23;
  --text: #f2f2f7;
  --text-secondary: #8e8e93;
  --primary: #10A66B;
  --primary-dark: #0E9F6E;
  --gold: #F4A300;
  --success: #34c759;
  --danger: #ff453a;
  --border: #2c2c2e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.subtitle {
  color: var(--text-secondary);
  margin: 0 0 24px;
  font-size: 14px;
}

#loginForm input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
}

#loginForm button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
}

/* App */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

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

.badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.btn-danger {
  background: var(--danger);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-success {
  background: var(--success);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 56px;
  z-index: 9;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 14px 0;
  margin-right: 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

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

.card h2 {
  margin: 0 0 16px;
  font-size: 17px;
}

.card-head h2 { margin-bottom: 0; }

label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

input[type="text"], input[type="number"], input[type="url"], input[type="file"], select, textarea {
  display: block;
  width: 100%;
  padding: 11px 13px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

input[type="file"] { padding: 10px; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 600px) {
  .row { grid-template-columns: 1fr; }
}

button[type="submit"] {
  margin-top: 8px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#subStatusFilter {
  width: auto;
  margin: 0;
}

.hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 14px;
}

.hint code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.result {
  margin-top: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow: auto;
  color: var(--text-secondary);
}

/* Submissions */
.submissions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.submission-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: stretch;
}

.submission-row .thumb {
  width: 280px;
  height: 280px;
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
  border: 1px solid var(--border);
}

.submission-row .thumb::after {
  content: '🔍';
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.submission-row .thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.submission-row .body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.submission-row .place-name {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
}

.submission-row .place-address {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.submission-row .meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 14px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 4px;
}

.submission-row .meta-grid dt {
  color: var(--text-secondary);
  font-weight: 500;
}

.submission-row .meta-grid dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
}

.submission-row .meta-grid dd.amount {
  color: var(--gold);
  font-weight: 700;
}

.submission-row .meta-grid dd a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.submission-row .reject-note {
  background: rgba(255, 69, 58, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.submission-row .actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
}

.submission-row .actions button {
  flex: 1;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}

@media (max-width: 760px) {
  .submission-row {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 14px;
  }
  .submission-row .thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    max-height: 360px;
  }
}

.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
  font-size: 13px;
}

/* Places */
.places-search {
  width: 320px;
  max-width: 100%;
  margin: 0;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
}

.places-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .places-list { grid-template-columns: 1fr; }
}

.place-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.place-row .info { flex: 1; min-width: 0; }
.place-row .name {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.place-row .meta {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-row .actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.place-row .actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
}

.place-row .actions .delete:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Screenshot modal */
.screenshot-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.screenshot-modal img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.1);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  color: white;
  cursor: pointer;
}

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

.reject-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
}

.reject-content h3 {
  margin: 0 0 16px;
  font-size: 17px;
}

.reject-content textarea {
  resize: vertical;
  min-height: 80px;
}

.reject-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ============== Manual review tab ============== */

.badge-warning { background: #f59e0b; color: #1f2937; }
.badge-danger  { background: #ef4444; color: #fff; }

.manual-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #1f2735;
  border-radius: 8px;
  margin: 0 16px 12px;
  flex-wrap: wrap;
}
.concurrency-label {
  display: flex; align-items: center; gap: 8px;
  color: #cbd5e1; font-size: 13px;
}
.concurrency-label input {
  width: 56px;
  padding: 4px 6px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  text-align: center;
}
.queue-state {
  flex: 1;
  text-align: right;
  color: #94a3b8;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.queue-state--active {
  color: #38bdf8;
  font-weight: 500;
}

.btn-primary {
  background: #2563eb; color: #fff; border: none;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 500;
}
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.manual-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 16px 16px;
}

.manual-card {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 20px;
  background: #1f2735;
  border-radius: 12px;
  padding: 16px;
  position: relative;
  border: 1px solid transparent;
}
.manual-card.is-checking {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, .25);
}

.manual-card__left .thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 500px;
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
  cursor: zoom-in;
  display: flex; align-items: center; justify-content: center;
}
.manual-card__left .thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.manual-card__right { min-width: 0; }

.reason-row {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  border-left: 4px solid;
}
.reason-row .reason-badge { font-weight: 600; margin-right: 6px; }
.reason-danger  { background: rgba(239, 68, 68, .12);  border-color: #ef4444; color: #fecaca; }
.reason-warn    { background: rgba(245, 158, 11, .12); border-color: #f59e0b; color: #fde68a; }
.reason-info    { background: rgba(56, 189, 248, .12); border-color: #38bdf8; color: #bae6fd; }
.reason-neutral { background: rgba(148, 163, 184, .12); border-color: #94a3b8; color: #cbd5e1; }

.manual-card .meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.manual-card .meta-grid dt { color: #94a3b8; }
.manual-card .meta-grid dd { color: #e2e8f0; margin: 0; word-break: break-word; }
.manual-card .meta-grid dd a { color: #38bdf8; }

.ocr-text-block {
  background: #0f172a;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.ocr-text-block h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #94a3b8;
  font-weight: 600;
}
.ocr-text-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  color: #e2e8f0;
  max-height: 180px;
  overflow-y: auto;
}

.candidates-block { margin-bottom: 12px; }
.candidates-block h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #94a3b8;
  font-weight: 600;
}
.candidates-head { font-size: 12px; color: #94a3b8; margin-bottom: 6px; }
.candidates-err { color: #fecaca; }
.candidates-hint { font-style: italic; }
.candidates-meta { color: #94a3b8; }

.candidates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.candidates-table th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 500;
  color: #94a3b8;
  border-bottom: 1px solid #334155;
}
.candidates-table td {
  padding: 6px 8px;
  vertical-align: top;
  border-bottom: 1px solid #1e293b;
}
.candidates-table tr:hover td { background: rgba(56, 189, 248, .06); }
.cell-author { white-space: nowrap; }
.cell-author a { color: #38bdf8; }
.cell-date { white-space: nowrap; color: #94a3b8; }
.cell-rating { width: 30px; color: #fbbf24; text-align: center; }
.cell-text {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.cell-pick { width: 80px; }

.manual-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #334155;
  flex-wrap: wrap;
}

/* ============== Log panel ============== */

.log-card { position: sticky; bottom: 0; }
.log-controls {
  display: flex; gap: 12px; align-items: center;
}
.log-filter {
  display: flex; align-items: center; gap: 6px;
  color: #94a3b8; font-size: 13px; cursor: pointer;
}
.log-panel {
  background: #0a0f1c;
  border-radius: 0 0 8px 8px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  height: 260px;
  overflow-y: auto;
  padding: 8px 12px;
  border-top: 1px solid #1e293b;
}
.log-row {
  display: grid;
  grid-template-columns: 70px 56px 80px 1fr;
  gap: 10px;
  padding: 2px 0;
  line-height: 1.45;
  border-bottom: 1px dotted #1e293b;
}
.log-ts { color: #64748b; }
.log-lvl { font-weight: 600; }
.log-id { color: #94a3b8; }
.log-msg { color: #e2e8f0; white-space: pre-wrap; word-break: break-word; }

.log-row--info  .log-lvl { color: #38bdf8; }
.log-row--warn  .log-lvl { color: #f59e0b; }
.log-row--warn  { background: rgba(245, 158, 11, .04); }
.log-row--error .log-lvl { color: #ef4444; }
.log-row--error { background: rgba(239, 68, 68, .06); }

@media (max-width: 900px) {
  .manual-card { grid-template-columns: 1fr; }
  .manual-card__left .thumb { max-height: 320px; aspect-ratio: auto; }
  .cell-text { max-width: 200px; -webkit-line-clamp: 2; }
}
