:root {
    color-scheme: light;
    --bg: #f4f6f3;
    --surface: #ffffff;
    --ink: #1f2528;
    --muted: #667178;
    --line: #d7ded5;
    --accent: #2f4a3a;
    --accent-dark: #203328;
    --green: #2f4a3a;
    --red: #a43d34;
    --shadow: 0 14px 40px rgba(31, 37, 40, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(20px, 4vw, 56px);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

h1, h2, h3, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(24px, 3vw, 34px);
}

a {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.button-link,
.primary-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 9px 13px;
}

.button-link:hover,
.primary-link:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

main {
    width: min(1240px, calc(100% - 32px));
    margin: 28px auto 60px;
}

.generate-form,
.toolbar {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.toolbar .search-input {
    flex: 1 1 420px;
}

label, legend {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input, select, textarea, button {
    font: inherit;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
}

select {
    min-height: 42px;
    height: 42px;
    appearance: auto;
}

textarea {
    resize: vertical;
    line-height: 1.45;
}

button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    min-height: 44px;
    padding: 10px 16px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

button:hover {
    border-color: var(--accent);
}

button.primary,
.generate-form button {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

button.primary:hover,
.generate-form button:hover {
    background: var(--accent-dark);
}

button.danger {
    color: var(--red);
}

button.ghost {
    border-color: transparent;
    background: transparent;
    padding-inline: 8px;
}

.small-button {
    padding: 8px 11px;
}

.notice {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 700;
}

.notice.success {
    background: #e9f4ee;
    color: var(--green);
}

.notice.error {
    background: #f8e9e7;
    color: var(--red);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stats article,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
    color: var(--ink);
}

.stats span,
.stat-card span {
    display: block;
    font-size: 30px;
    font-weight: 900;
}

.stats small,
.stat-card small {
    color: var(--muted);
    font-weight: 700;
}

.nav,
.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: end;
    gap: 10px;
}

.header-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.header-form input {
    width: 64px;
    padding: 9px 8px;
}

.header-form button,
.header-actions > a {
    font-size: 13px;
}

.topbar h1 a {
    color: var(--ink);
}

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

.login-box,
.install-box {
    width: min(520px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-box {
    display: grid;
    gap: 8px;
}

.login-box button {
    margin-top: 14px;
    justify-self: center;
}

.install-box {
    width: min(760px, 100%);
}

.install-form {
    display: grid;
    gap: 14px;
}

.settings-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.user-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    background: #fbfdfb;
}

.permissions-box {
    grid-column: 1 / -1;
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.permissions-box label {
    color: var(--ink);
}

.users-table {
    display: grid;
    gap: 8px;
}

.users-head,
.users-row {
    display: grid;
    grid-template-columns: minmax(190px, 1.2fr) minmax(210px, 1.2fr) repeat(4, minmax(80px, 0.55fr)) 48px;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
}

.users-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.users-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.users-row small {
    display: block;
    color: var(--accent);
    font-weight: 900;
    margin-top: 3px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--accent);
    background: #fff;
    font-size: 20px;
    font-weight: 900;
}

.manual-form {
    display: grid;
    grid-template-columns: minmax(320px, 460px) minmax(420px, 1fr);
    align-items: start;
    gap: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}

.upload-start-form {
    display: grid;
    grid-template-columns: minmax(320px, 520px) minmax(340px, 1fr);
    gap: 18px;
    align-items: start;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.upload-start-form > .field:first-of-type {
    grid-column: 2;
    grid-row: 1;
}

.upload-start-form > .field:nth-of-type(2) {
    grid-column: 2;
    grid-row: 2;
}

.upload-start-form > .field:nth-of-type(3) {
    grid-column: 2;
    grid-row: 3;
}

.field .optional {
    color: var(--muted);
    font-weight: 600;
}

.field small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    line-height: 1.45;
}

.crop-empty {
    grid-column: 1;
    grid-row: 1 / span 5;
    min-height: 520px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #eef2ec;
    color: var(--muted);
    font-weight: 800;
    text-align: center;
    padding: 24px;
}

.crop-empty[hidden] {
    display: none !important;
}

.crop-picker {
    display: contents;
}

.crop-picker[hidden] {
    display: none !important;
}

.crop-stage {
    grid-column: 1;
    grid-row: 1 / span 5;
    position: relative;
    width: min(100%, 520px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #eef2ec;
    touch-action: none;
}

.crop-stage img {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
}

.crop-frame {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #fff;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(47, 74, 58, 0.9);
    cursor: move;
}

.crop-frame span {
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(255, 255, 255, 0.65);
}

.crop-controls {
    grid-column: 2;
    grid-row: 3;
    display: grid;
    gap: 8px;
}

.crop-controls input {
    padding-inline: 0;
}

.crop-controls small {
    color: var(--muted);
    line-height: 1.45;
}

.split-actions {
    grid-column: 2;
    grid-row: 4;
    justify-content: start;
    gap: 10px;
}

.upload-preview {
    display: grid;
    grid-column: 1;
    grid-row: 1 / span 6;
    gap: 10px;
    align-content: start;
}

.upload-preview img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 680px;
    aspect-ratio: auto;
    object-fit: contain;
    margin-inline: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #eef2ec;
}

.upload-preview span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.manual-form .wide,
.manual-form .actions,
.manual-form .inline {
    grid-column: 2;
}

.manual-form > .field {
    grid-column: 2;
}

.manual-form .form-grid {
    grid-column: 2;
}

.actions.start {
    justify-content: start;
    align-items: center;
    gap: 8px;
}

.queue-note {
    min-height: 42px;
    display: flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf7;
    color: var(--muted);
    font-weight: 800;
    padding: 10px 12px;
}

.actions a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 16px;
    font-weight: 800;
}

.settings-form button,
.settings-help,
.slot-preview {
    grid-column: 1 / -1;
}

.settings-help {
    color: var(--muted);
    line-height: 1.45;
}

.slot-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.slot-preview span {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf7;
    color: var(--accent);
    font-weight: 900;
    padding: 8px 10px;
}

.muted {
    color: var(--muted);
}

.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.board + .board {
    margin-top: 34px;
}

.compact-board {
    display: none;
}

.section-title h2 {
    margin-bottom: 0;
    font-size: 24px;
}

.section-title p {
    max-width: 620px;
    margin-bottom: 0;
    color: var(--muted);
}

.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    text-align: center;
}

.post-list {
    display: grid;
    gap: 18px;
}

.table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--muted);
    font-weight: 700;
}

.bulk-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px;
    background: var(--surface);
}

.mini-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.mini-row img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    background: #eee9e2;
}

.mini-row span {
    color: var(--muted);
    font-weight: 700;
}

.product-table {
    display: grid;
    gap: 10px;
}

.product-row {
    display: grid;
    grid-template-columns: 28px 76px minmax(250px, 1.3fr) minmax(250px, 1fr) 150px;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.row-actions {
    display: flex;
    justify-content: end;
    gap: 8px;
}

.product-row img {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 8px;
    background: #eee9e2;
}

.product-row h3 {
    margin-bottom: 5px;
    font-size: 16px;
}

.product-row p {
    margin-bottom: 4px;
    color: var(--muted);
}

.select-cell input,
.inline input {
    width: auto;
}

.inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-grid {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 13px;
}

.date-grid strong {
    color: var(--ink);
}

.post-card {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.post-card.status-approved {
    border-color: rgba(47, 74, 58, 0.45);
}

.post-card.status-rejected {
    opacity: 0.72;
}

.post-media {
    background: #eee9e2;
    min-height: 100%;
}

.post-media img {
    width: 100%;
    height: 100%;
    min-height: 260px;
    object-fit: cover;
    display: block;
}

.post-body {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.post-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.post-heading h3 {
    margin-bottom: 5px;
    font-size: 20px;
}

.post-heading p {
    color: var(--muted);
    margin-bottom: 0;
}

.post-heading a {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.status {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 8px;
}

.status-row .status {
    margin-bottom: 0;
}

.post-select {
    display: inline-flex;
    align-items: center;
}

.post-select input {
    width: auto;
}

.published-text {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfaf8;
    padding: 14px;
    line-height: 1.55;
    max-height: 360px;
    overflow: auto;
}

.published-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.field {
    display: grid;
    gap: 7px;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
    gap: 14px;
}

.channels {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.channels label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
}

.channels input {
    width: auto;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.card-footer small {
    color: var(--muted);
    font-weight: 700;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: end;
    gap: 6px;
}

.product-detail {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}

.product-detail img {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
}

.history-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.history-grid > div,
.history-line {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.history-line {
    margin-bottom: 10px;
}

.history-modal {
    width: min(620px, calc(100% - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0;
}

.history-modal::backdrop {
    background: rgba(31, 37, 40, 0.35);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding: 16px 18px;
}

.modal-head h2 {
    margin: 0;
    font-size: 20px;
}

.history-modal pre {
    margin: 0;
    padding: 18px;
    white-space: pre-wrap;
    font: inherit;
    color: var(--ink);
    line-height: 1.55;
}

@media (max-width: 820px) {
    .topbar,
    .section-title,
    .card-footer,
    .post-heading {
        align-items: stretch;
        flex-direction: column;
    }

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

    .post-card,
    .form-grid,
    .manual-form,
    .upload-start-form,
    .url-start-form,
    .user-form,
    .product-row,
    .product-detail,
    .history-grid {
        grid-template-columns: 1fr;
    }

    .manual-form .wide,
    .manual-form .actions,
    .manual-form .inline,
    .manual-form > .field,
    .manual-form .form-grid,
    .crop-empty,
    .upload-start-form > .field:first-of-type,
    .upload-start-form > .field:nth-of-type(2),
    .crop-picker,
    .crop-stage,
    .crop-controls,
    .split-actions {
        grid-column: 1;
        grid-row: auto;
    }

    .crop-picker {
        grid-template-columns: 1fr;
    }

    .permissions-box,
    .user-form .actions {
        grid-column: 1;
    }

    .users-head {
        display: none;
    }

    .users-row {
        grid-template-columns: 1fr 1fr;
    }

    .upload-preview {
        grid-column: 1;
        grid-row: auto;
    }

    .row-actions {
        justify-content: stretch;
    }

    .row-actions button {
        width: 100%;
    }

    .post-media img {
        height: 260px;
    }

    .generate-form {
        align-items: stretch;
    }

    .header-actions,
    .header-form {
        justify-content: stretch;
    }

    .header-form input,
    .header-form button,
    .header-actions > a {
        width: 100%;
    }
}


.creation-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 22px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.creation-divider::before,
.creation-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
}

.url-start-form {
    display: grid;
    grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.4fr);
    gap: 18px 24px;
    align-items: end;
    background: #fbfdfb;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.url-start-copy {
    grid-row: 1 / span 2;
    align-self: center;
}

.url-start-copy h3 {
    margin: 4px 0 8px;
    font-size: 22px;
}

.url-start-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.url-start-form .actions {
    justify-content: flex-start;
}

@media (max-width: 820px) {
    .url-start-form {
        grid-template-columns: 1fr;
    }

    .url-start-copy {
        grid-row: auto;
    }
}
