* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f7fb;
    color: #1f2937;
    font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

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

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

.site-header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

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

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

.nav a {
    padding: 8px 12px;
    border-radius: 6px;
    color: #4b5563;
}

.nav a:hover,
.nav a.active {
    background: #e9f2ff;
    color: #1557a5;
}

.main {
    padding: 28px 0 48px;
}

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

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

h1,
h2 {
    margin: 0;
    color: #111827;
    letter-spacing: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.25;
}

h2 {
    font-size: 20px;
    line-height: 1.35;
    margin-bottom: 16px;
}

p {
    margin: 6px 0 0;
    color: #6b7280;
}

.panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.narrow-panel {
    max-width: 720px;
}

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

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

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    font-weight: 600;
    color: #374151;
}

input[type="text"],
input[type="search"],
input[type="file"],
select,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #111827;
    font: inherit;
    padding: 10px 12px;
    outline: none;
}

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

input:focus,
textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    width: fit-content;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1f2937;
    font: inherit;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    white-space: nowrap;
}

.button:hover {
    background: #f8fafc;
}

.button.primary {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

.button.primary:hover {
    background: #1e40af;
}

.button.danger {
    background: #ffffff;
    border-color: #fecaca;
    color: #b91c1c;
}

.button.danger:hover {
    background: #fef2f2;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert-success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}

.alert-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

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

.section-title h2 {
    margin-bottom: 0;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.search-form input {
    min-width: 240px;
}

.search-form select {
    width: auto;
    min-width: 160px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 14px;
    font-weight: 700;
}

td {
    color: #1f2937;
}

.empty {
    text-align: center;
    color: #6b7280;
    padding: 28px 10px;
}

.inline-form {
    display: inline;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 3px 10px;
    font-weight: 700;
    white-space: nowrap;
}

.status.pass {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.status.waiting {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.status.invalid {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #d1d5db;
}

.break-text {
    word-break: break-all;
}

.history-table {
    min-width: 1280px;
}

.history-table .history-domain {
    min-width: 150px;
    white-space: nowrap;
}

.history-table .history-url {
    min-width: 280px;
    max-width: 380px;
    word-break: normal;
    overflow-wrap: anywhere;
}

.history-table .history-final {
    min-width: 130px;
}

.history-table .history-cashback {
    min-width: 140px;
    width: 140px;
}

.history-table .history-operation {
    min-width: 120px;
}

.history-table .cashback-history-select {
    gap: 4px;
    font-size: 13px;
}

.history-table .cashback-history-select .button {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 13px;
    white-space: nowrap;
}

.danger-zone {
    border-color: #fecaca;
}

.review-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.review-summary span {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    background: #eff6ff;
    color: #1e3a8a;
    padding: 8px 12px;
}

.review-list {
    display: grid;
    gap: 16px;
    padding-bottom: 86px;
}

.merchant-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    padding: 18px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.merchant-card.excluded {
    background: #fff1f2;
    border-color: #fecdd3;
}

.merchant-card.has-history {
    border-color: #bfdbfe;
}

.merchant-card.history-used {
    border-color: #bae6fd;
    background: #f0f9ff;
}

.merchant-card.excluded .merchant-card-head h2,
.merchant-card.excluded .merchant-card-head p,
.merchant-card.excluded .candidate-block {
    text-decoration: line-through;
    color: #9f1239;
}

.merchant-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.merchant-card h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.merchant-card h3 {
    font-size: 16px;
    margin: 18px 0 8px;
    color: #374151;
}

.merchant-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}

.candidate-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.candidate-list li {
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f8fafc;
    color: #334155;
    padding: 4px 10px;
    word-break: break-all;
}

.history-notice {
    margin-top: 16px;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e5e7eb;
}

.history-notice.known {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.history-notice.fresh {
    background: #f8fafc;
    border-color: #e5e7eb;
}

.history-title,
.history-actions,
.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.history-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 14px;
    margin: 12px 0;
    color: #475569;
}

.history-choice-status {
    color: #1e3a8a;
}

.empty-inline {
    margin: 0;
    color: #6b7280;
}

.next-step-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    border-top: 1px solid #dbe3ef;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

.next-step-inner {
    width: min(1180px, calc(100% - 32px));
    min-height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.next-step-inner span {
    color: #475569;
}

@media (max-width: 760px) {
    .container {
        width: min(100% - 24px, 1180px);
    }

    .header-inner,
    .page-head,
    .section-title {
        align-items: stretch;
        flex-direction: column;
    }

    .nav,
    .search-form {
        width: 100%;
    }

    .nav a,
    .search-form .button,
    .page-head .button {
        flex: 1;
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 16px;
    }

    h1 {
        font-size: 24px;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form input {
        min-width: 0;
    }

    .button {
        width: 100%;
    }

    .history-table .cashback-history-select .button {
        width: auto;
    }

    .merchant-card-head,
    .merchant-actions,
    .page-actions,
    .next-step-inner {
        align-items: stretch;
        flex-direction: column;
    }

    .history-details {
        grid-template-columns: 1fr;
    }

    .next-step-inner {
        padding: 12px 0;
    }

    .review-list {
        padding-bottom: 140px;
    }
}
