:root {
    color-scheme: light;
    --bg: #eef3f4;
    --surface: #ffffff;
    --surface-soft: #f8fbfb;
    --ink: #172023;
    --muted: #637176;
    --line: #d8e0e2;
    --accent: #16756f;
    --accent-dark: #0f5550;
    --accent-warm: #c4573f;
    --header: #152023;
    --header-ink: #f5fbfb;
    --green: #2f7d57;
    --red: #a43d34;
    --shadow: 0 16px 42px rgba(23, 32, 35, 0.10);
}

* {
    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: grid;
    grid-template-columns: minmax(220px, 0.55fr) minmax(0, 2fr);
    align-items: center;
    gap: 24px;
    padding: 14px max(24px, calc((100vw - 1440px) / 2));
    background: var(--header);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 10px 32px rgba(21, 32, 35, 0.20);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent-warm);
    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;
}

main {
    width: min(1440px, calc(100% - 40px));
    margin: 22px 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, textarea, button {
    font: inherit;
}

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

select {
    font: inherit;
    font-weight: 800;
}

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

button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 14px;
    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(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.stats article,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 0;
    padding: 16px 18px;
    box-shadow: 0 10px 28px rgba(23, 32, 35, 0.08);
    color: var(--ink);
}

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

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

.stat-card {
    border-top: 3px solid var(--line);
}

.stat-card.stat-pending {
    border-top-color: #d59639;
}

.stat-card.stat-approved {
    border-top-color: var(--accent);
}

.stat-card.stat-published {
    border-top-color: var(--green);
}

.metrics-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin-bottom: 26px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
}

.metrics-strip a {
    color: var(--muted);
    font-size: 13px;
}

.metrics-strip strong {
    color: var(--ink);
}

.metrics-strip .has-errors,
.metrics-strip .has-errors strong {
    color: var(--red);
}

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

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

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

.active-channel {
    margin: 4px 0 0;
    color: rgba(245, 251, 251, 0.68);
    font-size: 13px;
    font-weight: 800;
}

.channel-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.06);
}

.dashboard-board {
    display: grid;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 22px;
    box-shadow: 0 12px 32px rgba(23, 32, 35, 0.06);
}

.dashboard-title {
    margin: 0;
}

.section-kicker {
    margin-bottom: 4px !important;
    color: var(--accent) !important;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.primary-link {
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
}

.queue-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.queue-summary article {
    display: grid;
    gap: 5px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 16px;
}

.queue-summary small,
.queue-summary span {
    color: var(--muted);
}

.queue-summary strong {
    font-size: 21px;
}

.queue-summary span {
    font-size: 13px;
}

.channel-tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border-radius: 6px;
    padding: 7px 12px;
    color: rgba(245, 251, 251, 0.78);
    font-size: 13px;
    font-weight: 850;
}

.channel-tabs a:hover,
.channel-tabs a.is-active {
    background: var(--surface);
    color: var(--ink);
}

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

.topbar .header-actions > a {
    color: rgba(245, 251, 251, 0.82);
}

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

.topbar h1 {
    font-size: clamp(24px, 2.2vw, 30px);
    white-space: nowrap;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(22, 117, 111, 0.16), transparent 34%),
        linear-gradient(315deg, rgba(196, 87, 63, 0.13), transparent 32%),
        #eef3f4;
}

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

.login-box {
    border-top: 6px solid var(--accent);
}

.login-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 8px;
    margin-bottom: 18px;
    background: var(--header);
    color: var(--header-ink);
    font-weight: 950;
}

.login-copy {
    max-width: 390px;
    color: var(--muted);
    line-height: 1.45;
}

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

.login-box button {
    margin-top: 16px;
}

.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;
}

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

.settings-form .wide-field {
    grid-column: 1 / -1;
}

.channel-settings-form {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    align-items: start;
}

.channel-settings-form .channels {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    align-items: center;
    gap: 10px;
    background: var(--surface-soft);
}

.channel-settings-form .meta-toggle {
    grid-column: 1 / -1;
}

.toggle-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 10px 12px;
    color: var(--ink);
}

.toggle-line input {
    width: auto;
}

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

.field-note {
    margin: -6px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

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

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

.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-soft);
    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);
}

.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-profile {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}

.type-badge,
.readiness-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 850;
    line-height: 1.2;
}

.type-badge {
    background: #e8f1f1;
    color: var(--accent-dark);
}

.readiness-badge.is-ready {
    background: #e6f3eb;
    color: var(--green);
}

.readiness-badge.needs-work {
    background: #fff0dc;
    color: #8a5713;
}

.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: 0 10px 26px rgba(23, 32, 35, 0.07);
    overflow: hidden;
}

.post-card.status-approved {
    border-color: rgba(47, 125, 87, 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: var(--surface-soft);
    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;
}

.schedule-preview,
.queue-hint {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    padding: 12px 14px;
}

.schedule-preview {
    display: grid;
    gap: 6px;
}

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

.published-row img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 6px;
}

.published-row h3 {
    margin: 4px 0;
    font-size: 17px;
}

.published-row p {
    margin: 0;
    color: var(--muted);
}

.image-note {
    color: var(--muted);
    font-size: 13px;
}

.config-output {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
    white-space: pre-wrap;
}

.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: 1180px) {
    .topbar {
        grid-template-columns: 1fr;
        position: static;
    }

    .header-actions {
        justify-content: start;
    }

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

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

    main {
        width: min(100% - 24px, 1440px);
        margin-top: 14px;
    }

    .topbar h1 {
        white-space: normal;
    }

    .stats,
    .queue-summary {
        grid-template-columns: 1fr;
    }

    .stat-card {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
    }

    .stat-card span {
        font-size: 26px;
    }

    .post-card,
    .form-grid,
    .settings-form,
    .product-row,
    .product-detail,
    .history-grid,
    .published-row {
        grid-template-columns: 1fr;
    }

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

    .row-actions button,
    .row-actions .small-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%;
    }

    .channel-tabs {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .channel-tabs a {
        justify-content: center;
    }

    .dashboard-actions,
    .dashboard-actions a {
        width: 100%;
    }

    .settings-form .wide-field {
        grid-column: 1 / -1;
    }
}
