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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1a1a1a;
  background: #f5f5f5;
}

/* ─── Nav ─────────────────────────────────────────────────────────────── */

nav {
  background: #1c2b3a;
  color: #fff;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav .nav-brand {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  text-decoration: none;
}

nav .nav-user {
  font-size: 0.85rem;
  color: #b0bec5;
  display: flex;
  align-items: center;
  gap: 1rem;
}

nav .nav-user a {
  color: #90caf9;
  text-decoration: none;
}

nav .nav-user a:hover {
  text-decoration: underline;
}

/* ─── Main content ─────────────────────────────────────────────────────── */

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

h1 { font-size: 1.6rem; margin: 0 0 1.5rem; font-weight: 600; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; font-weight: 600; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }

p { margin: 0 0 0.75rem; }

a { color: #1565c0; }

/* ─── Messages ─────────────────────────────────────────────────────────── */

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.messages .success { background: #e8f5e9; border-left: 4px solid #43a047; }
.messages .error   { background: #ffebee; border-left: 4px solid #e53935; }
.messages .warning { background: #fff8e1; border-left: 4px solid #fb8c00; }
.messages .info    { background: #e3f2fd; border-left: 4px solid #1e88e5; }

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 4px;
  border: none;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn-primary {
  background: #1565c0;
  color: #fff;
}
.btn-primary:hover { background: #0d47a1; color: #fff; }

.btn-secondary {
  background: #fff;
  color: #1565c0;
  border: 1px solid #1565c0;
}
.btn-secondary:hover { background: #e3f2fd; }

.btn-danger {
  background: #fff;
  color: #c62828;
  border: 1px solid #c62828;
}
.btn-danger:hover { background: #ffebee; }

.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.82rem;
}

.btn-muted {
  background: #eceff1;
  color: #546e7a;
  border: 1px solid #cfd8dc;
}
.btn-muted:hover { background: #cfd8dc; }

/* ─── Forms ───────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: #37474f;
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: #1a1a1a;
  transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #1565c0;
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}

textarea { min-height: 120px; resize: vertical; }

.form-hint {
  font-size: 0.82rem;
  color: #78909c;
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.82rem;
  color: #c62828;
  margin-top: 0.25rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-row .form-group { flex: 1; margin-bottom: 0; }

/* ─── Tables ──────────────────────────────────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  background: #eceff1;
  font-weight: 600;
  font-size: 0.82rem;
  color: #546e7a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #cfd8dc;
}

td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid #eceff1;
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* ─── Cards / panels ──────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

/* ─── Status badges ───────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-pending    { background: #fff8e1; color: #f57f17; }
.badge-generating { background: #e3f2fd; color: #1565c0; }
.badge-ready      { background: #e8f5e9; color: #2e7d32; }
.badge-failed     { background: #ffebee; color: #c62828; }

/* ─── Article review ──────────────────────────────────────────────────── */

.article-excluded td {
  opacity: 0.5;
}

/* ─── Report content ──────────────────────────────────────────────────── */

.report-content {
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.7;
  background: #fff;
  border: 1px solid #eceff1;
  border-radius: 4px;
  padding: 1.5rem;
}

/* ─── Utility ─────────────────────────────────────────────────────────── */

.text-muted { color: #78909c; font-size: 0.88rem; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.spacer { flex: 1; }

/* ─── Login page ─────────────────────────────────────────────────────── */

.login-wrap {
  max-width: 380px;
  margin: 5rem auto;
  padding: 0 1rem;
}

.login-wrap h1 {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
}

/* ─── Generating indicator ─────────────────────────────────────────────── */

.generating-notice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #1565c0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #90caf9;
  border-top-color: #1565c0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
