:root {
    --bg: #f5f1ea;
    --panel: #fffdf9;
    --panel-soft: #f0e8db;
    --text: #1e1c19;
    --muted: #6e675e;
    --line: #ddd2c3;
    --accent: #7a4b2b;
    --accent-soft: #f4e3d2;
    --success: #2f6b46;
    --danger: #8b2f2f;
    --shadow: 0 18px 40px rgba(53, 35, 19, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    background:
        radial-gradient(circle at top left, rgba(244, 227, 210, 0.9), transparent 30%),
        linear-gradient(180deg, #f8f4ee, #efe8de 65%, #ece2d6);
    color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
    padding: 28px 22px;
    background: rgba(255,253,249,0.86);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--line);
}
.brand { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.brand-note { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.nav a {
    display: block;
    padding: 11px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    color: var(--text);
}
.nav a.active, .nav a:hover { background: var(--accent-soft); }
.content { padding: 28px 32px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-title { font-size: 30px; margin: 0; }
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 22px;
}
.panel h2, .panel h3 { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }
.stat { padding: 18px; border-radius: 16px; background: var(--panel-soft); }
.compact-stats .stat { padding: 14px 16px; }
.compact-stats .stat-value { font-size: 18px; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-value { font-size: 28px; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
td.actions, th.col-actions { white-space: nowrap; width: 190px; }
td.actions { display: flex; align-items: center; justify-content: flex-start; gap: 8px; flex-wrap: nowrap; }
td.actions .btn, td.actions button, td.actions a { flex: 0 0 auto; }
td.actions.actions-wide, th.col-actions-wide { white-space: normal; width: 340px; }
td.actions.actions-wide { flex-wrap: wrap; align-items: stretch; }
.btn, button {
    border: 0;
    border-radius: 12px;
    min-height: 42px;
    padding: 10px 14px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover, button:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(53, 35, 19, 0.12); text-decoration: none; }
.btn.secondary, button.secondary {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--line);
}
.btn.danger, button.danger { background: var(--danger); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 8px; font-size: 14px; }
.field input, .field select, .field textarea {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font: inherit;
}
.field input.field-success {
    border-color: #63a36d;
    box-shadow: 0 0 0 3px rgba(99, 163, 109, 0.12);
}
.field input.field-error {
    border-color: #b34a4a;
    box-shadow: 0 0 0 3px rgba(179, 74, 74, 0.12);
}
.field textarea { min-height: 140px; resize: vertical; }
.field-hint { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.offer-job-fields {
    display: grid;
    gap: 14px;
}
.offer-url-status {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #f8f3ec;
    color: var(--muted);
    font-size: 13px;
}
.offer-url-status.is-success {
    border-color: #bdd8c4;
    background: #e6f3ea;
    color: var(--success);
}
.offer-url-status.is-error {
    border-color: #e4bbbb;
    background: #f7e3e3;
    color: var(--danger);
}
.filters {
    padding: 16px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel-soft);
}
.action-stack { display: flex; flex-direction: column; justify-content: flex-end; }
pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f8f3ec;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    max-height: 480px;
    overflow: auto;
}
ul { padding-left: 22px; }
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: min(460px, 100%);
    padding: 28px;
    border-radius: 24px;
    background: rgba(255,253,249,0.95);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.login-card form button { width: 100%; margin-top: 8px; }
.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.flash.success { background: #e6f3ea; color: var(--success); border-color: #bdd8c4; }
.flash.error { background: #f7e3e3; color: var(--danger); border-color: #e4bbbb; }
.flash.info { background: #ece6de; color: var(--text); border-color: #d9cec0; }
.meta { color: var(--muted); font-size: 13px; }
.warning-text { color: #9a6516; }
.pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--panel-soft);
    font-size: 12px;
}
.pill.status-queued, .pill.status-pending { background: #f4e7c7; color: #7d5b11; }
.pill.status-running { background: #dfe8f7; color: #28508d; }
.pill.status-paused { background: #e8e2da; color: #5b4b3f; }
.pill.status-completed, .pill.status-success { background: #e3f0e5; color: #2f6b46; }
.pill.status-failed, .pill.status-error { background: #f5dfdf; color: #8b2f2f; }
.code {
    font-family: "Courier New", monospace;
    background: #f8f3ec;
    padding: 2px 6px;
    border-radius: 6px;
}
.url-preview {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.provider-secret {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: "Courier New", monospace;
}
.template-name {
    display: block;
    overflow-wrap: anywhere;
}
.template-scope {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.proxy-address {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.draft-cover-preview {
    display: block;
    max-width: 100%;
    border-radius: 16px;
    border: 1px solid var(--line);
    margin-top: 10px;
}
.offer-image-grid {
    display: grid;
    gap: 14px;
}
.offer-image-grid-hero {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.offer-image-grid-body {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.offer-image-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 251, 245, 0.92);
    padding: 12px;
}
.offer-image-card img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
    margin-bottom: 8px;
}
.draft-content-preview {
    border: 1px solid var(--line);
    background: rgba(255, 251, 245, 0.92);
    border-radius: 18px;
    padding: 20px;
}
.draft-content-preview section + section {
    margin-top: 20px;
}
.draft-content-preview .offer-hero-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.draft-content-preview .offer-hero-image,
.draft-content-preview .offer-body-image {
    margin: 18px 0;
}
.draft-content-preview .offer-hero-image img,
.draft-content-preview .offer-body-image img {
    display: block;
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--line);
}
.draft-content-preview h1,
.draft-content-preview h2,
.draft-content-preview h3 {
    margin-top: 0;
}
.timeline {
    display: grid;
    gap: 14px;
}
.timeline-item {
    display: grid;
    grid-template-columns: 165px 1fr;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fffaf4;
}
.timeline-time {
    color: var(--muted);
    font-size: 12px;
}
.timeline-body {
    display: grid;
    gap: 6px;
}
.timeline-item.status-success {
    border-color: #bdd8c4;
    background: #f7fbf8;
}
.timeline-item.status-error {
    border-color: #e4bbbb;
    background: #fff5f5;
}
.timeline-item.status-pending {
    border-color: #e7d49d;
    background: #fffaf0;
}
@media (max-width: 960px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 14px; }
    td.actions, th.col-actions { width: auto; white-space: normal; }
    td.actions { flex-wrap: wrap; }
    .timeline-item { grid-template-columns: 1fr; }
}
