:root {
    --bg: #f6f1e7;
    --panel: #ffffff;
    --text: #1a1b1f;
    --muted: #6b6c72;
    --primary: #1a1b1f;
    --primary-2: #36373c;
    --accent: #c39634;
    --danger: #b42318;
    --success: #15803d;
    --radius: 14px;
    --shadow: 0 14px 30px rgba(8, 23, 38, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 0%, rgba(195, 150, 52, 0.10), transparent 32%),
        radial-gradient(circle at 85% 5%, rgba(26, 27, 31, 0.07), transparent 30%),
        var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

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

.sidebar {
    background: linear-gradient(180deg, #1a1b1f 0%, #2a2c31 100%);
    color: #f6f1e7;
    padding: 26px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 6px;
}

.brand-subtitle {
    color: #d6d7da;
    font-size: 0.88rem;
    margin-bottom: 26px;
}

.menu {
    display: grid;
    gap: 8px;
}

.menu a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: #f0e8d8;
    transition: 0.2s ease;
}

.menu a:hover,
.menu a.active {
    background: rgba(195, 150, 52, 0.28);
    color: #ffffff;
}

.main {
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.page-title {
    font-size: 1.4rem;
    margin: 0;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.card h3,
.card h2 {
    margin-top: 0;
}

.kpi {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 8px;
}

.muted {
    color: var(--muted);
    font-size: 0.92rem;
}

.form-grid {
    display: grid;
    gap: 12px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input,
select,
textarea,
button {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d2dce4;
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
}

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

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    cursor: pointer;
    font-weight: 600;
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
}

button.secondary,
.button.secondary {
    background: #31475a;
}

button.accent,
.button.accent {
    background: var(--accent);
    color: #101820;
}

button.danger,
.button.danger {
    background: var(--danger);
}

button.success,
.button.success {
    background: var(--success);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid #edf1f4;
    vertical-align: top;
    font-size: 0.92rem;
}

th {
    color: #3d566a;
    font-weight: 700;
}

.badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 5px 9px;
    background: #e7eef4;
    color: #30485c;
}

.badge.preview_ready { background: #d8f0f8; color: #14516a; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.posted { background: #dbeafe; color: #1d4ed8; }
.badge.failed { background: #fee2e2; color: #991b1b; }
.badge.draft,
.badge.generated { background: #f1f5f9; color: #475569; }
.badge.archived { background: #ece7f9; color: #5b3ea8; }

.flash-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.flash {
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.flash.success {
    background: #dcfce7;
    color: #166534;
}

.flash.error {
    background: #fee2e2;
    color: #991b1b;
}

.preview-box {
    background: #f5f8fa;
    border: 1px solid #dce7ef;
    border-radius: 12px;
    padding: 10px;
}

.preview-box img {
    width: 100%;
    border-radius: 10px;
}

.small {
    font-size: 0.84rem;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 26px;
}

.progress-modal {
    position: fixed;
    inset: 0;
    z-index: 99;
    display: grid;
    place-items: center;
    background: rgba(12, 15, 19, 0.5);
    backdrop-filter: blur(3px);
    padding: 20px;
}

.progress-modal[hidden] {
    display: none !important;
}

.progress-panel {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 28px 56px rgba(8, 23, 38, 0.22);
    padding: 22px;
    border: 1px solid #e6ebef;
}

.progress-panel h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.progress-track {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: #ecf0f4;
    overflow: hidden;
    margin-top: 14px;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #c39634 0%, #e1b54b 100%);
    transition: width 0.32s ease;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.progress-error {
    margin-top: 10px;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 0.9rem;
}

@media (max-width: 1060px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: relative;
    }

    .grid.cols-3,
    .grid.cols-2 {
        grid-template-columns: 1fr;
    }
}
