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

:root {
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --primary: #4f6ef7;
  --primary-hover: #3a57e8;
  --danger: #e53935;
  --success: #2e7d32;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

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

/* Top bar */
.top-bar {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px;
}

.btn-admin {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
}
.btn-admin:hover { border-color: var(--primary); color: var(--primary); background: rgba(79,110,247,.05); }

/* Layout */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
}

@media (max-width: 480px) {
  .card { padding: 28px 20px; }
}

.title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.subtitle { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 28px; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(79,110,247,.04);
}
.drop-icon { width: 40px; height: 40px; color: var(--muted); margin: 0 auto 12px; display: block; }
.drop-text { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.drop-hint { color: #9ca3af; font-size: 12px; margin-top: 12px; }

.btn-choose {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s;
}
.btn-choose:hover { background: var(--primary-hover); }

/* File info */
.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 12px;
}
.file-info svg { width: 24px; height: 24px; color: var(--primary); flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; }
.file-name { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.btn-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px; line-height: 1; transition: color .2s; }
.btn-remove:hover { color: var(--danger); }

/* Submit button */
.btn-submit {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}
.btn-submit:hover:not(:disabled) { background: var(--primary-hover); }
.btn-submit:disabled { opacity: .45; cursor: not-allowed; }

/* Error message */
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* Processing */
.processing-section { text-align: center; padding: 16px 0; }
.spinner-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-label { font-size: 15px; font-weight: 500; color: var(--text); }
.processing-hint { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Result */
.result-card {
  border: 1px solid #d1fae5;
  background: #f0fdf4;
  border-radius: var(--radius);
  padding: 24px;
}
.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.result-header svg { width: 22px; height: 22px; color: #16a34a; flex-shrink: 0; }
.result-header h2 { font-size: 16px; font-weight: 600; color: #166534; }
.result-text {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.btn-copy {
  margin-top: 16px;
  background: none;
  border: 1px solid #86efac;
  color: #16a34a;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
}
.btn-copy:hover { background: #dcfce7; }

.btn-again {
  width: 100%;
  margin-top: 16px;
  padding: 11px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
}
.btn-again:hover { border-color: var(--primary); color: var(--primary); }

/* Error card */
.error-card {
  border: 1px solid #fecaca;
  background: #fff5f5;
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.error-card svg { width: 22px; height: 22px; color: var(--danger); flex-shrink: 0; margin-top: 1px; }
.error-card p { font-size: 14px; line-height: 1.6; color: #b91c1c; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  padding: 36px 32px;
  width: 100%; max-width: 400px;
  position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 18px; color: var(--muted); cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal-hint { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.modal-input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none;
  transition: border-color .2s;
}
.modal-input:focus { border-color: var(--primary); }
.btn-primary {
  width: 100%; margin-top: 14px;
  padding: 11px; background: var(--primary); color: #fff;
  font-size: 14px; font-weight: 600; border: none; border-radius: 8px; cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover { background: var(--primary-hover); }

.success-msg { color: var(--success); font-size: 13px; margin-top: 10px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  background: none; border: none; padding: 8px 14px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .2s, border-color .2s;
  display: flex; align-items: center; gap: 6px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }

.badge {
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 10px; line-height: 1.4;
}

/* Logs */
.logs-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.logs-label { font-size: 12px; color: var(--muted); }
.btn-refresh {
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-size: 12px; padding: 4px 10px;
  border-radius: 6px; cursor: pointer; transition: all .2s;
}
.btn-refresh:hover { border-color: var(--primary); color: var(--primary); }

.logs-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto;
}
.logs-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 20px 0; }

.log-entry {
  border-radius: 8px; padding: 9px 12px; font-size: 12px; line-height: 1.5;
}
.log-entry.error { background: #fff5f5; border: 1px solid #fecaca; }
.log-entry.warn  { background: #fffbeb; border: 1px solid #fde68a; }
.log-entry.info  { background: #f0f9ff; border: 1px solid #bae6fd; }

.log-entry .log-time { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.log-entry .log-msg  { font-weight: 500; color: var(--text); }
.log-entry .log-detail { color: var(--muted); margin-top: 3px; word-break: break-all; }

/* Utility */
.hidden { display: none !important; }
