*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #2d2d2d;
    background: #fafafa;
    margin: 0;
    line-height: 1.5;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */

header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 1.5rem 0;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

header h1 a {
    color: #2d2d2d;
    text-decoration: none;
}

.tagline {
    margin: 0.25rem 0 0;
    color: #666;
    font-size: 0.9rem;
}

/* Main */

main { padding: 2rem 0; }

/* Footer */

footer {
    border-top: 1px solid #e0e0e0;
    padding: 1rem 0;
    margin-top: 3rem;
    color: #888;
    font-size: 0.8rem;
}

footer a {
    color: #4a7c9e;
    text-decoration: none;
}

footer a:hover { text-decoration: underline; }

/* Form */

.input-group { margin-bottom: 1rem; }

.input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    resize: vertical;
    background: #fff;
}

textarea:focus {
    outline: none;
    border-color: #4a7c9e;
    box-shadow: 0 0 0 2px rgba(74, 124, 158, 0.15);
}

input[type="file"] { font-size: 0.9rem; }

.input-divider {
    text-align: center;
    color: #999;
    font-size: 0.85rem;
    margin: 0.75rem 0;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    align-items: center;
}

button[type="submit"] {
    background: #4a7c9e;
    color: #fff;
    border: none;
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

button[type="submit"]:hover { background: #3d6a88; }

.htmx-indicator {
    display: none;
    margin-left: 0.75rem;
    color: #666;
    font-size: 0.9rem;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline;
}

/* Export bar */

.export-bar {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.btn-export {
    background: #fff;
    color: #4a7c9e;
    border: 1px solid #4a7c9e;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.btn-export:hover {
    background: #4a7c9e;
    color: #fff;
}

/* Results */

.results { margin-top: 2rem; }

.results section { margin-bottom: 2rem; }

.results h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.35rem;
}

/* PO header card */

.po-header {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.header-top h2 {
    margin: 0;
    font-size: 1.25rem;
}

.retailer-badge {
    background: #4a7c9e;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.po-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 0;
}

.po-meta div {
    display: flex;
    gap: 0.4rem;
}

.po-meta dt {
    color: #888;
    font-size: 0.85rem;
    font-weight: 400;
}

.po-meta dt::after { content: ":"; }

.po-meta dd {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Tables */

.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: #fff;
}

.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555;
    border-bottom: 2px solid #ddd;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.data-table th.num,
.data-table td.num { text-align: right; }

.data-table .mono {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.82rem;
}

.data-table.compact { max-width: 400px; }

.detail-row td {
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    color: #666;
    font-size: 0.82rem;
    border-bottom: 1px solid #f0f0f0;
}

/* Badges */

.badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
    margin-left: 0.4rem;
}

.badge-warn {
    background: #fff3cd;
    color: #856404;
}

/* Addresses */

.address-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.address-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 0.75rem 1rem;
}

.address-card h4 {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
}

.address-card p {
    margin: 0.15rem 0;
    font-size: 0.85rem;
}

.address-name { font-weight: 500; }

.address-id {
    color: #888;
    font-size: 0.8rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Totals */

.totals .po-meta {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 0.75rem 1rem;
}

/* Mode tabs */

.mode-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.mode-tab {
    background: none;
    border: none;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.mode-tab:hover { color: #555; }

.mode-tab.active {
    color: #4a7c9e;
    border-bottom-color: #4a7c9e;
}

.mode-description {
    color: #666;
    font-size: 0.9rem;
    margin: 0 0 1.25rem;
}

.input-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.input-group-retailer { max-width: 220px; }

.input-group-retailer select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff;
}

.input-group-retailer select:focus {
    outline: none;
    border-color: #4a7c9e;
    box-shadow: 0 0 0 2px rgba(74, 124, 158, 0.15);
}

/* Validation results */

.validation-header {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.validation-summary {
    margin-bottom: 2rem;
}

.summary-counts {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.summary-stat {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.75rem 1.25rem;
    text-align: center;
    min-width: 100px;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.stat-pass { color: #27ae60; }
.stat-fail { color: #c0392b; }
.stat-fee { color: #e67e22; }

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.15rem;
}

/* Findings */

.layer-description {
    color: #888;
    font-size: 0.82rem;
    margin: -0.5rem 0 0.75rem;
}

.findings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.finding {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #ccc;
    border-radius: 4px;
    padding: 0.75rem 1rem;
}

.finding-blocks-transmission { border-left-color: #c0392b; }
.finding-will-cause-chargeback { border-left-color: #e67e22; }
.finding-may-cause-chargeback { border-left-color: #f1c40f; }
.finding-cosmetic { border-left-color: #95a5a6; }

.finding-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.finding-segment {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    color: #555;
    background: #f5f5f5;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

.finding-fee {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e67e22;
    margin-left: auto;
}

.finding-message {
    margin: 0;
    font-size: 0.87rem;
    color: #333;
}

.finding-location {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: #888;
}

/* Severity badges */

.badge-pass {
    background: #d4edda;
    color: #155724;
}

.badge-severity-blocks-transmission {
    background: #f8d7da;
    color: #721c24;
}

.badge-severity-will-cause-chargeback {
    background: #ffeeba;
    color: #856404;
}

.badge-severity-may-cause-chargeback {
    background: #fff3cd;
    color: #856404;
}

.badge-severity-cosmetic {
    background: #e2e6ea;
    color: #555;
}

.badge-sm {
    font-size: 0.65rem;
    padding: 0.05rem 0.3rem;
}

/* Validation pass */

.validation-pass-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    padding: 1.25rem;
}

.validation-pass-message p {
    margin: 0;
    color: #155724;
    font-size: 0.9rem;
}

/* Chargeback summary */

.chargeback-summary { margin-top: 2rem; }

.data-table tfoot td {
    padding: 0.6rem 0.75rem;
    border-top: 2px solid #ddd;
    background: #f5f5f5;
}

/* Error panel */

.error-panel {
    margin-top: 2rem;
    background: #fff;
    border: 1px solid #e8c4c4;
    border-left: 4px solid #c0392b;
    border-radius: 4px;
    padding: 1rem 1.25rem;
}

.error-panel h3 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    color: #c0392b;
    border: none;
    padding: 0;
}

.error-message { margin: 0 0 0.5rem; font-size: 0.9rem; }

.error-hint {
    margin: 0;
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

/* CTA section */

.cta-section {
    margin-top: 2rem;
    background: #f0f6fa;
    border: 1px solid #c8dce8;
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.cta-section h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: #2d2d2d;
    border: none;
    padding: 0;
}

.cta-section p {
    margin: 0 0 1rem;
    color: #555;
    font-size: 0.9rem;
}

.btn-cta {
    display: inline-block;
    background: #4a7c9e;
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn-cta:hover { background: #3a6a8a; }

.mode-panel-hidden { display: none; }

/* Try-a-sample link */

.try-sample {
    font-size: 0.85rem;
    color: #4a7c9e;
    cursor: pointer;
    background: none;
    border: none;
    text-decoration: underline;
    padding: 0;
    margin-bottom: 1rem;
    display: inline-block;
}

.try-sample:hover { color: #3a6a8a; }

/* Responsive */

@media (max-width: 768px) {
    .container { padding: 0 1rem; }
    header h1 { font-size: 1.25rem; }
    .po-meta { grid-template-columns: 1fr 1fr; }
    .address-grid { grid-template-columns: 1fr; }
    .summary-counts { flex-wrap: wrap; }
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 600px; }
    .input-row { flex-direction: column; }
}

@media (max-width: 480px) {
    .po-meta { grid-template-columns: 1fr; }
    .mode-tabs { flex-direction: column; }
    .mode-tab { border-radius: 4px; }
    .export-bar { flex-direction: column; gap: 0.5rem; }
    .finding-header { flex-wrap: wrap; }
}
