/* assets/style.css */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fbfd;
    --ink: #172026;
    --muted: #627081;
    --line: #dfe6ee;
    --line-strong: #c6d1dc;
    --green: #2f8a57;
    --green-soft: #e8f6ee;
    --blue: #2367d1;
    --blue-soft: #eaf1ff;
    --amber: #b7791f;
    --amber-soft: #fff4dc;
    --red: #c24135;
    --red-soft: #fff0ee;
    --violet: #6d5bd0;
    --shadow: 0 16px 40px rgba(23, 32, 38, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, #ffffff 0, var(--bg) 260px),
        var(--bg);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

.container {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 78px;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    color: #ffffff;
    background: var(--green);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(47, 138, 87, 0.22);
}

.brand-mark h1,
.brand-mark p,
.section-heading h2,
.section-heading p {
    margin: 0;
}

.brand-mark h1 {
    font-size: 22px;
    line-height: 1.1;
    letter-spacing: 0;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    white-space: nowrap;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.68;
    transform: none;
}

.button-primary {
    color: #ffffff;
    background: var(--blue);
    box-shadow: 0 10px 22px rgba(35, 103, 209, 0.18);
}

.button-ai {
    color: #ffffff;
    background: var(--violet);
    box-shadow: 0 10px 22px rgba(109, 91, 208, 0.18);
}

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

.button-ghost {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
}

.button-ghost:hover {
    border-color: var(--line-strong);
    box-shadow: 0 10px 22px rgba(23, 32, 38, 0.08);
}

.app-main {
    padding: 28px 0 56px;
}

.notice {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
    padding: 14px 16px;
    border-radius: var(--radius);
    font-weight: 700;
}

.notice-error {
    color: var(--red);
    background: var(--red-soft);
    border: 1px solid #ffd2cc;
}

.settings-panel,
.stats-grid,
.toolbar,
.product-card,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.settings-panel {
    margin-bottom: 22px;
    padding: 22px;
}

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

.section-heading h2 {
    font-size: 21px;
    letter-spacing: 0;
}

.settings-grid,
.prompt-grid,
.form-grid {
    display: grid;
    gap: 16px;
}

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

.prompt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.field > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

input,
textarea,
select {
    width: 100%;
    min-width: 0;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input,
select {
    height: 42px;
    padding: 0 12px;
}

textarea {
    padding: 12px;
    resize: vertical;
    min-height: 96px;
}

input:focus,
textarea:focus,
select:focus {
    background: #ffffff;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(35, 103, 209, 0.12);
}

textarea.is-updated,
input.is-updated {
    background: var(--green-soft);
    border-color: #9ed8b6;
}

.inline-status,
.status-msg {
    min-height: 22px;
    color: var(--muted);
    font-weight: 800;
}

.msg-success {
    color: var(--green) !important;
}

.msg-error {
    color: var(--red) !important;
}

.bulk-progress-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 50;
    width: min(420px, calc(100vw - 32px));
    padding: 16px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(23, 32, 38, 0.18);
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    backdrop-filter: blur(14px);
}

.bulk-progress-panel.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.bulk-progress-panel.is-complete {
    border-color: #9ed8b6;
    box-shadow: 0 0 0 2px rgba(47, 152, 92, 0.12), 0 20px 60px rgba(23, 32, 38, 0.16);
}

.bulk-progress-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.bulk-progress-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    color: #ffffff;
    background: var(--violet);
    border-radius: var(--radius);
}

.bulk-progress-label,
.bulk-progress-current {
    margin: 0;
}

.bulk-progress-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.bulk-progress-head strong {
    display: block;
    margin-top: 2px;
    font-size: 18px;
    line-height: 1.2;
}

.bulk-progress-current {
    min-height: 22px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bulk-progress-track {
    height: 8px;
    margin: 12px 0;
    overflow: hidden;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.bulk-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--blue);
    border-radius: inherit;
    transition: width 0.2s ease;
}

.bulk-progress-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.bulk-progress-stats span {
    padding: 10px;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 900;
}

.bulk-progress-stats strong {
    color: var(--ink);
    font-size: 20px;
    line-height: 1;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(23, 32, 38, 0.42);
    backdrop-filter: blur(10px);
}

.modal-panel {
    width: min(760px, 100%);
    max-height: min(780px, calc(100vh - 48px));
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 28px 90px rgba(23, 32, 38, 0.28);
}

.night-modal {
    padding: 22px;
}

.modal-header,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.modal-header {
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0;
}

.night-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 12px 14px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.night-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    background: var(--green);
    border-radius: 999px;
    box-shadow: 0 0 0 5px rgba(47, 138, 87, 0.14);
}

.night-current {
    min-height: 24px;
    margin: 14px 0;
    color: var(--muted);
    font-weight: 800;
}

.night-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.night-stats div {
    padding: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.night-stats span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.night-stats strong {
    display: block;
    margin-top: 6px;
    font-size: 30px;
    line-height: 1;
}

.night-log {
    display: grid;
    gap: 8px;
    min-height: 120px;
    max-height: 220px;
    overflow: auto;
    padding: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.night-log p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.night-log a {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.night-log a:hover {
    color: var(--ink);
}

.night-log-success {
    color: var(--green) !important;
}

.night-log-error {
    color: var(--red) !important;
}

.modal-actions {
    justify-content: flex-end;
    padding-top: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr;
    gap: 1px;
    overflow: hidden;
    margin-bottom: 18px;
    padding: 0;
}

.stat-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
    min-height: 120px;
    padding: 20px;
    background: var(--surface);
}

.stat-block + .stat-block {
    border-left: 1px solid var(--line);
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.stat-block strong {
    font-size: 34px;
    line-height: 1;
    letter-spacing: 0;
}

.stat-block small {
    color: var(--muted);
}

.progress-track {
    width: 100%;
    height: 10px;
    overflow: hidden;
    background: #e7edf4;
    border-radius: 999px;
}

.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: inherit;
}

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

.pagination-form label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 800;
}

.pagination-form select {
    width: 92px;
}

.pagination {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    color: var(--muted);
    font-weight: 800;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

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

.product-card {
    position: relative;
    overflow: hidden;
    padding: 22px;
}

.product-card.is-edited {
    border-color: #8bd3a4;
    box-shadow: 0 0 0 2px rgba(47, 152, 92, 0.16), var(--shadow);
}

.product-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--amber);
}

.product-card.is-edited::before {
    background: var(--green);
}

.product-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.product-title {
    min-width: 0;
}

.product-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.product-meta span,
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.status-pill {
    color: var(--amber);
    background: var(--amber-soft);
    border-color: #f1d69d;
}

.is-edited .status-pill {
    color: var(--green);
    background: var(--green-soft);
    border-color: #bfe4cc;
}

.product-header h2 {
    margin: 0;
    font-size: 21px;
    line-height: 1.25;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

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

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

.field-counter {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: right;
}

.field-counter.is-over {
    color: var(--red);
}

.form-actions {
    justify-content: flex-start;
    margin-top: 18px;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 260px;
    padding: 36px;
    text-align: center;
}

.empty-state i {
    color: var(--blue);
    font-size: 34px;
}

.empty-state h2,
.empty-state p {
    margin: 0;
}

.empty-state p {
    color: var(--muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(180deg, #ffffff 0, #f5f7fb 60%),
        #f5f7fb;
}

.login-shell {
    width: min(460px, 100%);
}

.login-panel {
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.login-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.login-form .button {
    width: 100%;
    margin-top: 4px;
}

@media (max-width: 1180px) {
    .topbar-inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 0;
    }

    .topbar-actions {
        justify-content: flex-start;
        width: 100%;
    }

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

@media (max-width: 860px) {
    .container {
        width: min(100% - 20px, 1440px);
    }

    .settings-grid,
    .prompt-grid,
    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .stat-block + .stat-block {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .toolbar,
    .product-header,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination,
    .product-actions,
    .topbar-actions {
        justify-content: flex-start;
    }

    .button {
        white-space: normal;
    }

    .modal-header,
    .modal-actions {
        align-items: stretch;
        flex-direction: column;
    }

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

@media (max-width: 540px) {
    .topbar-actions,
    .form-actions,
    .product-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .button {
        width: 100%;
    }

    .settings-panel,
    .product-card,
    .login-panel {
        padding: 18px;
    }

    .stat-block strong {
        font-size: 28px;
    }

    .bulk-progress-panel {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
    }

    .bulk-progress-stats {
        grid-template-columns: 1fr;
    }

    .modal-overlay {
        padding: 10px;
    }

    .night-modal {
        padding: 18px;
    }

    .night-stats {
        grid-template-columns: 1fr;
    }
}
