:root {
    color-scheme: light;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #65717f;
    --border: #dfe5ec;
    --accent: #1f7a5a;
    --accent-dark: #14563f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Noto Sans KR", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px clamp(20px, 5vw, 64px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-size: 18px;
    font-weight: 700;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px 16px;
    color: var(--muted);
    font-size: 14px;
}

.nav a {
    overflow-wrap: anywhere;
}

.nav a:hover {
    color: var(--text);
}

.page {
    width: min(1040px, calc(100% - 40px));
    margin: 0 auto;
    padding: 56px 0;
}

.hero {
    display: grid;
    align-content: center;
    min-height: 420px;
}

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

h1 {
    margin: 0;
    font-size: clamp(40px, 7vw, 72px);
    line-height: 1.05;
}

.lead {
    max-width: 620px;
    margin: 20px 0 32px;
    color: var(--muted);
    font-size: 22px;
    line-height: 1.6;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
}

.button:hover {
    background: var(--accent-dark);
}

.dashboard-heading {
    margin-bottom: 24px;
}

.dashboard-heading h1 {
    font-size: 36px;
}

.page-subtitle {
    max-width: 680px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.status-card {
    min-height: 132px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.status-card p {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 14px;
}

.status-card strong {
    display: block;
    font-size: 28px;
    line-height: 1.2;
}

.status-card span {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.warning-card {
    border-color: #e2a4a4;
    background: #fff8f5;
}

.ok-card {
    border-color: #9acdb9;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 22px 0;
}

.billing-summary {
    margin-bottom: 32px;
}

.billing-section {
    margin-top: 32px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.section-heading h2 {
    margin: 0;
    font-size: 22px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.data-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 15px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    color: var(--muted);
    font-weight: 700;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table .is-current td {
    background: #edf7f3;
    font-weight: 700;
}

.product-list {
    display: grid;
    gap: 12px;
}

.product-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.product-row h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

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

.secondary-button {
    border: 1px solid var(--border);
    background: #eef1f4;
    color: var(--muted);
    cursor: not-allowed;
}

.secondary-button:hover {
    background: #eef1f4;
}

.link-button {
    cursor: pointer;
}

.notice {
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.notice strong {
    display: block;
    margin-bottom: 6px;
}

.notice p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.error-notice {
    border-color: #e2a4a4;
    background: #fff5f5;
}

.success-notice {
    border-color: #9acdb9;
    background: #f1fbf6;
}

.muted-notice {
    background: #f8fafc;
}

.media-list,
.comment-list {
    display: grid;
    gap: 14px;
}

.media-row,
.comment-row,
.empty-state {
    display: grid;
    gap: 18px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.media-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.media-row h2,
.comment-row h2 {
    margin: 0 0 10px;
    font-size: 20px;
    line-height: 1.35;
}

.media-row p,
.comment-row p,
.empty-state p {
    margin: 0 0 6px;
    color: var(--muted);
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.comment-actions {
    display: grid;
    gap: 12px;
}

.comment-actions form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.comment-actions form:nth-child(2) {
    grid-template-columns: minmax(0, 1.4fr) minmax(140px, 0.8fr) minmax(180px, 1fr) auto;
}

.comment-actions label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.comment-actions input {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

.split-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.rule-list,
.automation-form {
    display: grid;
    gap: 16px;
}

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

.rule-row h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.rule-row p {
    margin: 0 0 7px;
    color: var(--muted);
    line-height: 1.45;
}

.secondary-action {
    border: 1px solid var(--border);
    background: #eef1f4;
    color: var(--text);
}

.secondary-action:hover {
    background: #e4e9ee;
}

.form-section {
    display: grid;
    gap: 18px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.automation-form small {
    color: var(--muted);
    font-weight: 400;
    line-height: 1.4;
}

.step-heading {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.step-heading > div {
    min-width: 0;
}

.step-heading span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
}

.step-heading h2 {
    margin: 0 0 6px;
    font-size: 22px;
}

.step-heading p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.segmented label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    font-weight: 700;
}

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

.media-select-card {
    display: grid;
    gap: 10px;
    align-content: start;
    min-height: 180px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.media-select-card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 6px;
    background: #e7ecf2;
}

.media-select-card strong {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.media-select-card span,
.media-select-card small {
    overflow-wrap: anywhere;
    color: var(--muted);
    line-height: 1.4;
}

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

.compact-grid {
    grid-template-columns: repeat(2, minmax(120px, 180px));
}

.automation-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.automation-form input[type="text"],
.automation-form input[type="number"],
.automation-form input:not([type]),
.automation-form textarea,
.automation-form select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

.automation-form textarea {
    resize: vertical;
}

.preview-box {
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.preview-box p {
    margin: 0;
    color: var(--muted);
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(120px, 0.7fr) minmax(150px, 0.8fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.filter-bar label,
.debug-form label,
.inline-check {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.filter-bar input,
.filter-bar select,
.debug-form input,
.debug-form textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-weight: 400;
}

.log-list,
.job-list,
.debug-form {
    display: grid;
    gap: 14px;
}

.log-row,
.job-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.log-row h2,
.job-row h3 {
    margin: 0 0 8px;
    font-size: 20px;
}

.log-row p,
.job-row p {
    margin: 0 0 6px;
    color: var(--muted);
    line-height: 1.45;
}

.log-row time {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 28px;
    margin: 0 0 10px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.status-on {
    border-color: #9acdb9;
    background: #edf7f3;
    color: var(--accent-dark);
}

.status-off {
    background: #eef1f4;
}

.connection-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.connection-card,
.settings-row {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.connection-card p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 14px;
}

.connection-card strong {
    display: block;
    margin-bottom: 10px;
    font-size: 22px;
    line-height: 1.25;
}

.connection-card span,
.settings-row p {
    color: var(--muted);
    line-height: 1.5;
}

.settings-list {
    display: grid;
    gap: 14px;
}

.settings-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
}

.settings-row h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.settings-row p {
    margin: 0;
}

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

.inline-check input {
    width: auto;
    min-height: auto;
}

@media (max-width: 760px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        justify-content: flex-start;
    }

    .page {
        width: min(100% - 32px, 1040px);
        padding: 40px 0;
    }

    .hero {
        min-height: 360px;
    }

    .lead {
        font-size: 18px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .product-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .media-row,
    .comment-actions form,
    .comment-actions form:nth-child(2) {
        grid-template-columns: 1fr;
    }

    .row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .split-heading,
    .rule-row {
        align-items: flex-start;
        grid-template-columns: 1fr;
    }

    .media-card-grid,
    .form-grid,
    .compact-grid,
    .filter-bar,
    .log-row,
    .job-row,
    .connection-grid,
    .settings-row {
        grid-template-columns: 1fr;
    }

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

    .page-subtitle,
    .step-heading p,
    .empty-state p {
        word-break: break-all;
    }
}
