/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --cream:        #FDF8F2;
  --cream-dark:   #F5EDE0;
  --border:       #D4C5B0;
  --border-light: #EAE0D4;
  --text:         #1A1A1A;
  --text-muted:   #6B6560;
  --text-light:   #9E9890;
  --accent:       #C05A2A;
  --accent-hover: #A34A22;
  --gold:         #C9A84C;
  --gold-light:   #F0E4C0;
  --success:      #2D6A4F;
  --success-bg:   #D8F0E6;
  --error:        #9B2335;
  --error-bg:     #FADADD;
  --warning:      #7A5C00;
  --warning-bg:   #FFF4CC;

  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans:  'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:  'IBM Plex Mono', 'Courier New', monospace;

  --nav-height: 56px;
  --max-width:  1280px;
}

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

html { font-size: 16px; }

body {
  background: var(--cream);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Typography ────────────────────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

.mono { font-family: var(--font-mono); }

.label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Navigation ────────────────────────────────────────────────────────────── */
.nav {
  height: var(--nav-height);
  background: var(--text);
  border-bottom: 3px solid var(--accent);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--cream) !important;
  text-decoration: none;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.nav-brand span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #AAA !important;
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--cream) !important;
  background: rgba(255,255,255,0.08);
  text-decoration: none;
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user {
  font-size: 0.8rem;
  color: #888;
  font-family: var(--font-mono);
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.page-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
}

.page-header .label {
  margin-bottom: 0.4rem;
  display: block;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 1.5rem; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--cream-dark); color: var(--text); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border); }

.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}
.btn-danger:hover { background: var(--error-bg); }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.72rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-light); }

.form-error {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 0.3rem;
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 2px;
  font-size: 0.875rem;
  border-left: 3px solid;
  margin-bottom: 1rem;
}

.alert-error   { background: var(--error-bg);   border-color: var(--error);   color: var(--error); }
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: var(--gold);    color: var(--warning); }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.6rem 0.85rem;
  background: var(--cream-dark);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

tbody td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}

tbody tr:hover td { background: var(--cream-dark); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 2px;
}

.badge-pending    { background: var(--warning-bg); color: var(--warning); }
.badge-processing { background: #E0F0FF;           color: #1A5C9B; }
.badge-ready      { background: var(--success-bg); color: var(--success); }
.badge-failed     { background: var(--error-bg);   color: var(--error); }

/* ── Divider ───────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── HTMX loading indicator ────────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-mono   { font-family: var(--font-mono); }
.text-small  { font-size: 0.8rem; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Django messages ───────────────────────────────────────────────────────── */
.messages { list-style: none; margin-bottom: 1rem; }
