:root {
  --red: #c62828;
  --red-dark: #b71c1c;
  --gold: #ffb300;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { color: var(--red); font-size: 1.5rem; }
.login-card .subtitle { color: var(--muted); font-size: 0.875rem; margin: 8px 0 24px; }

.login-card label {
  display: block;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9375rem;
}

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

.header-brand { display: flex; align-items: center; gap: 14px; }
.header-brand .logo { font-size: 36px; }
.header-brand h1 { font-size: 1.25rem; color: var(--red); }
.header-brand p { font-size: 0.75rem; color: var(--gold); font-weight: 500; }
.header-actions { display: flex; gap: 10px; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
}

.tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.filters { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; }

.filters select,
.filters input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--card);
}

.filters input[type="search"] { min-width: 220px; flex: 1; }

.stats {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--red); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-icon { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); }

/* Table */
.table-wrap {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { background: #fafafa; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: #fafafa; }
td.empty { text-align: center; color: var(--muted); padding: 40px; }

.q-text {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.badge-easy { background: #dcfce7; color: #166534; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-hard { background: #fee2e2; color: #991b1b; }
.badge-cat { background: #ede9fe; color: #5b21b6; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.hidden { display: none !important; }
.error-msg { color: var(--danger); font-size: 0.8125rem; margin-top: 8px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 { font-size: 1.125rem; color: var(--red); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 14px;
}

label input,
label select,
label textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input { width: auto; margin: 0; }

.ai-paste-section {
  background: linear-gradient(135deg, #fef3c7 0%, #ede9fe 100%);
  border: 1px solid #e9d5ff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.ai-paste-header h3 {
  font-size: 0.9375rem;
  color: var(--red);
  margin-bottom: 4px;
}

.ai-paste-header p {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.ai-paste-section label { margin-bottom: 10px; }

.ai-verify-notice {
  font-size: 0.8125rem;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  line-height: 1.45;
}

.ai-verify-ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.ai-verify-warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0 18px;
}

.modal-xl {
  max-width: 900px;
}

.hint-text {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: -6px 0 14px;
  line-height: 1.45;
}

.pdf-review-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pdf-review-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pdf-progress {
  flex: 1;
  min-width: 200px;
}

.pdf-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.pdf-progress-fill {
  height: 100%;
  background: var(--red);
  width: 0%;
  transition: width 0.3s;
}

.pdf-progress span,
#pdfProgressText {
  font-size: 0.75rem;
  color: var(--muted);
}

.pdf-review-list {
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}

.pdf-review-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: #fafafa;
}

.pdf-review-card.processing {
  opacity: 0.7;
  border-color: var(--gold);
}

.pdf-review-card.error {
  border-color: var(--danger);
  background: #fff5f5;
}

.pdf-review-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pdf-review-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pdf-review-card-header h4 {
  font-size: 0.875rem;
  color: var(--red);
}

.pdf-review-card .options-grid {
  margin-bottom: 10px;
}

.pdf-review-card label {
  margin-bottom: 10px;
}

.pdf-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.pdf-status-pending { background: #f3f4f6; color: var(--muted); }
.pdf-status-processing { background: #fef3c7; color: #92400e; }
.pdf-status-done { background: #dcfce7; color: #166534; }
.pdf-status-error { background: #fee2e2; color: #991b1b; }

@media (max-width: 640px) {
  .options-grid { grid-template-columns: 1fr; }
  .header { flex-direction: column; align-items: flex-start; }
}
