* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f5f7;
    color: #1f2937;
}

.layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #111827;
    color: #fff;
    padding: 16px;
}

.sidebar a {
    display: block;
    color: #cbd5e1;
    text-decoration: none;
    padding: 8px 0;
}

.sidebar a.active {
    color: #fff;
    font-weight: 700;
}

.content {
    padding: 24px;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.login-wrap {
    max-width: 380px;
    margin: 80px auto;
}

.login-wrap input,
.login-wrap button {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
}

.error {
    color: #b91c1c;
}

.muted {
    color: #6b7280;
}

.center {
    text-align: center;
}

.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.module-header h2 {
    margin: 0;
}

button,
.btn-sm {
    border: 0;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    padding: 10px 12px;
    cursor: pointer;
}

button:disabled,
.btn-sm:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-sm {
    padding: 7px 10px;
    font-size: 12px;
    margin-right: 8px;
}

.btn-light {
    background: #e5e7eb;
    color: #111827;
}

.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.toolbar input,
.toolbar select {
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

.toolbar input {
    flex: 1;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

.table-wrap-results .data-table-results {
    min-width: 1120px;
}

.data-table-results .cell-wrap {
    max-width: 220px;
    word-break: break-word;
    white-space: normal;
}

.data-table-results .cell-match-basis {
    max-width: 160px;
    word-break: break-word;
}

.data-table-results .cell-product {
    max-width: 280px;
}

.data-table-results .cell-site {
    max-width: 180px;
    word-break: break-word;
}

.data-table-results th {
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #334155;
}

.data-table-results tbody tr:hover {
    background: #f8fafc;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.badge-confidence-high {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.badge-confidence-medium {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde047;
}

.badge-confidence-low {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.badge-confidence-muted {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    font-weight: 600;
}

.link-view-product {
    color: #1e40af;
    font-weight: 700;
    text-decoration: none;
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
}

.link-view-product:hover {
    text-decoration: none;
    background: #dbeafe;
}

.actions {
    white-space: nowrap;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.modal {
    width: 100%;
    max-width: 540px;
    background: #fff;
    border-radius: 10px;
    padding: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.icon-btn {
    background: transparent;
    color: #111827;
    font-size: 18px;
    padding: 2px 8px;
}

.modal label {
    display: block;
    margin: 12px 0 6px;
    font-weight: 700;
}

.modal input,
.modal textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px;
    font-family: Arial, sans-serif;
}

.modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

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

.form-grid label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.form-grid input,
.form-grid textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px;
    font-family: Arial, sans-serif;
}

.form-grid input:disabled,
.form-grid textarea:disabled {
    background: #f3f4f6;
    color: #6b7280;
}

.full-width {
    grid-column: 1 / -1;
}

.check-list {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    max-height: 240px;
    overflow: auto;
    padding: 8px;
    background: #f9fafb;
}

.check-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    border-radius: 8px;
}

.check-item:hover {
    background: #eef2ff;
}

.check-item span {
    display: flex;
    flex-direction: column;
}

.check-item small {
    color: #6b7280;
}

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

.badge-status-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-status-not-found {
    background: #fee2e2;
    color: #991b1b;
}

.badge-status-found {
    background: #dcfce7;
    color: #166534;
}

.badge-status-completed {
    background: #dcfce7;
    color: #166534;
}

/* Results View */
.results-action-bar {
    margin-bottom: 14px;
}

.results-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.result-summary-card {
    margin-bottom: 14px;
}

.result-summary-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.result-label {
    margin: 0;
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-product-name {
    margin: 6px 0 0;
    font-size: 24px;
    line-height: 1.3;
    color: #0f172a;
}

.result-price-chip {
    background: #0f172a;
    color: #f8fafc;
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 180px;
}

.result-price-chip .result-label {
    color: #cbd5e1;
}

.result-price-value {
    margin: 6px 0 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.result-meta-grid {
    margin-top: 12px;
}

.market-insight-card {
    margin-bottom: 14px;
}

.market-grid .full-width {
    margin-top: 2px;
}

.strategy-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.strategy-select {
    max-width: 360px;
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

.recommended-price-badge {
    display: inline-block;
    font-size: 1.2rem;
    font-weight: 800;
    color: #1e3a8a;
    background: #dbeafe;
    border: 2px solid #3b82f6;
    padding: 6px 14px;
    border-radius: 10px;
}

.decision-line {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-size: 15px;
}

.market-empty-note {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #475569;
}

/* New Price Check */
.price-check-card .price-check-lead {
    margin-top: 0;
    margin-bottom: 16px;
}

.form-banner {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 14px;
}

.form-banner.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.state-block {
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.state-block p {
    margin: 0;
}

.state-block p + p {
    margin-top: 8px;
}

.state-loading {
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    color: #4b5563;
}

.state-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.state-empty {
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    color: #374151;
}

.state-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: pc-spin 0.75s linear infinite;
    margin-bottom: 10px;
}

@keyframes pc-spin {
    to {
        transform: rotate(360deg);
    }
}

.form-actions {
    margin-top: 4px;
}

.form-actions button {
    min-width: 200px;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    gap: 16px;
}

.dash-cards {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.dash-card {
    border: 1px solid #1f2937;
    background: #111827;
    color: #f9fafb;
    border-radius: 10px;
    padding: 14px;
}

.dash-card-label {
    margin: 0 0 8px;
    font-size: 13px;
    color: #cbd5e1;
}

.dash-card-value {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.pricing-status-grid {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.pricing-status-pill {
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 600;
}

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

.pricing-status-slightly-high {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde047;
}

.pricing-status-high {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

@media (max-width: 1100px) {
    .dash-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 16px;
    }

    .dash-cards,
    .pricing-status-grid {
        grid-template-columns: 1fr;
    }

    .results-actions {
        justify-content: flex-start;
    }
}
