:root {
  --bg: #f4efe6;
  --panel: #fffdf8;
  --panel-strong: #f7f1e6;
  --ink: #1f1d1a;
  --muted: #6d665c;
  --line: #ddd2c0;
  --accent: #a33f1f;
  --accent-dark: #6f2410;
  --ok: #2f6b3b;
  --warn: #9b6b0c;
  --bad: #8b1e2d;
  --shadow: 0 20px 60px rgba(60, 35, 15, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(163, 63, 31, 0.08), transparent 32%),
    linear-gradient(180deg, #f8f4ed 0%, var(--bg) 100%);
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 24px;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark,
.login-hero .brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #d18c29 100%);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.brand-title { font-size: 1.1rem; font-weight: 700; }
.brand-subtitle { color: var(--muted); font-size: 0.9rem; }

.nav { display: grid; gap: 10px; }
.nav a {
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink);
}
.nav a:hover { background: var(--panel-strong); text-decoration: none; }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.user-chip { display: grid; gap: 2px; }
.user-chip span { color: var(--muted); font-size: 0.92rem; text-transform: capitalize; }

.content { padding: 28px; }
.auto-refresh-bar {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.auto-refresh-label {
  color: var(--muted);
  font-size: 0.92rem;
}
.auto-refresh-count {
  min-width: 2.8rem;
}
.auto-refresh-toggle {
  padding: 8px 12px;
  border-radius: 999px;
}
.auto-refresh-bar[data-paused="true"] .auto-refresh-count {
  color: var(--warn);
}
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.top-gap { margin-top: 20px; }

.grid { display: grid; gap: 20px; }
.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.four-up { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compact { gap: 12px; }
.stack { display: grid; gap: 14px; }
.fieldset {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.fieldset legend { padding: 0 8px; color: var(--muted); }

label { display: grid; gap: 6px; font-size: 0.95rem; }
label span { color: var(--muted); }
input, textarea, select, button {
  font: inherit;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 72px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-row input {
  width: 18px;
  height: 18px;
}

.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pill-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}
.pill-check input { width: auto; }

.primary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  cursor: pointer;
}
.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, #cd7b2d 100%);
  color: white;
}
.ghost-button {
  background: var(--panel-strong);
  color: var(--ink);
}
.danger-button {
  background: var(--bad);
  color: white;
}
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 6px;
}
.stat-card span { color: var(--muted); font-size: 0.92rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  text-align: left;
  border-top: 1px solid var(--line);
  padding: 12px 10px;
  vertical-align: top;
}
.data-table thead th {
  border-top: 0;
  color: var(--muted);
  font-weight: 600;
}

.status-chip {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}
.status-running { color: var(--warn); }
.status-completed { color: var(--ok); }
.status-failed { color: var(--bad); }
.status-queued { color: var(--muted); }

.code-box,
.log-box {
  background: #201d18;
  color: #f7f1e8;
  border-radius: 18px;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}
.small { min-height: 120px; max-height: 320px; }
.log-box { min-height: 320px; max-height: 520px; }
.log-line { margin-bottom: 8px; }
.muted { color: var(--muted); }
.form-error { color: var(--bad); }

.article-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.article-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}
.article-meta { color: var(--muted); margin-bottom: 8px; }
.article-links {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.login-hero {
  padding: 36px;
  background:
    linear-gradient(145deg, rgba(163,63,31,0.12), rgba(209,140,41,0.08)),
    var(--panel-strong);
}
.login-card form { padding: 36px; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .two-up, .four-up, .article-grid, .login-card, .stats-grid { grid-template-columns: 1fr; }
  .auto-refresh-bar {
    right: 16px;
    bottom: 16px;
    left: 16px;
    justify-content: space-between;
  }
}
