body {
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.06), transparent 28%),
        radial-gradient(circle at top right, rgba(15, 23, 42, 0.04), transparent 24%),
        #eef2f7;
    padding: 28px;
    color: #0f172a;
    line-height: 1.45;
}

.container {
    background: #ffffff;
    max-width: 1200px;
    padding: 28px;
    border-radius: 22px;
    border: 1px solid #dbe3ef;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
    margin: 0 auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e5eaf2;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand h2 {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.logo {
    height: 54px;
    width: auto;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.08));
}

.header-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.help-link,
.secondary-link {
    color: #1d4ed8;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    transition: 0.18s ease;
}

.help-link:hover,
.secondary-link:hover {
    background: #dbeafe;
    text-decoration: none;
}

fieldset {
    border: 2px solid #c7d2e3;
    border-radius: 18px;
    padding: 18px 18px 16px;
    margin-bottom: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

legend {
    padding: 0 10px;
    font-weight: 700;
    color: #334155;
    font-size: 15px;
}

.form-row {
    display: flex;
    margin-bottom: 14px;
    align-items: center;
    gap: 14px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row label {
    width: 180px;
    font-weight: 600;
    color: #334155;
}

.form-row input,
.form-row select,
.drawer-input,
.sort-form select {
    flex: 1;
    padding: 11px 12px;
    border: 2px solid #b6c4d6;
    border-radius: 12px;
    background: #ffffff;
    color: #0f172a;
    font-size: 15px;
    outline: none;
    transition: 0.18s ease;
    box-sizing: border-box;
}

.form-row input:focus,
.form-row select:focus,
.drawer-input:focus,
.sort-form select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}

button {
    margin-top: 10px;
    padding: 11px 18px;
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.16);
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(37, 99, 235, 0.22);
}

button.secondary {
    background: #f3f6fa;
    color: #0f172a;
    box-shadow: none;
    border: 1px solid #d6deea;
}

button.secondary:hover {
    background: #e8eef6;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #d7dee7;
}

.badge.ok,
.badge.fail {
    background: #f8fafc;
    color: #111827;
    border: 1px solid #d1d5db;
}

.result {
    margin-top: 24px;
    border: 2px solid #b6c4d6;
    background: linear-gradient(180deg, #f7fbff 0%, #eef4fb 100%);
    border-radius: 18px;
    padding: 20px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.result h3 {
    margin: 0 0 12px;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.columns,
.history-stats-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.history-stats-grid {
    grid-template-columns: 2.2fr 1fr;
    margin-top: 8px;
}

.result-columns {
    margin-top: 16px;
}

ul {
    margin: 10px 0 0;
    padding-left: 20px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
}

tr:last-child td {
    border-bottom: none;
}

.drawer-actions,
.history-actions {
    margin-top: 14px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.error {
    color: #991b1b;
    font-weight: 700;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 12px 14px;
    border-radius: 12px;
}

.warning {
    color: #111827;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    padding: 8px 10px;
    border-radius: 8px;
    margin-top: 10px;
}

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

.stat-card {
    border: 1px solid #dbe3ef;
    border-radius: 16px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.stat-card span {
    display: block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
}

.stat-card strong {
    font-size: 24px;
    letter-spacing: -0.02em;
}

.table-note,
.drawer-note {
    font-size: 12px;
    color: #64748b;
}

.sort-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.sort-form label {
    font-weight: 700;
    color: #334155;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: white;
    max-width: 680px;
    width: 100%;
    padding: 26px;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

.modal h3 {
    margin-top: 0;
}

.modal-close {
    float: right;
    cursor: pointer;
    font-weight: bold;
    color: #475569;
}

@media (max-width: 900px) {
    .columns,
    .history-stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    body {
        padding: 14px;
    }

    .container {
        padding: 18px;
        border-radius: 18px;
    }

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

    .form-row label {
        width: auto;
    }

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

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

    .header-links {
        gap: 8px;
    }

    .help-link,
    .secondary-link {
        justify-content: center;
    }

    .brand h2 {
        font-size: 24px;
    }
}


.receipt-link {
    display: inline-flex;
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
}


fieldset {
    position: relative;
}

fieldset::before {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    top: 0;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, #2563eb 0%, #93c5fd 100%);
    opacity: 0.9;
}


.history-stats-grid fieldset,
.columns > div > fieldset {
    border-width: 2px;
}

#history-section {
    scroll-margin-top: 20px;
}
