* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #1a1a1a;
}

h2 { font-size: 18px; margin-bottom: 12px; }

.add-form {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-row {
    display: flex;
    gap: 8px;
}

.form-row input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-row input:first-child { max-width: 250px; }

.form-row button, .btn-scan-all, .btn-scan, .btn-delete, .btn-save {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.form-row button {
    background: #2563eb;
    color: #fff;
}
.form-row button:hover { background: #1d4ed8; }

.actions-bar {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
}

.btn-scan-all {
    background: #059669;
    color: #fff;
}
.btn-scan-all:hover { background: #047857; }
.btn-scan-all:disabled { background: #9ca3af; cursor: wait; }

.link-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.link-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.link-name {
    font-size: 18px;
    font-weight: 600;
}

.link-url {
    font-size: 12px;
    color: #6b7280;
    word-break: break-all;
    margin-bottom: 12px;
}

.link-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.stat-value.median { color: #2563eb; }

.threshold-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.threshold-row label {
    font-size: 13px;
    color: #6b7280;
}

.threshold-row input {
    width: 120px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.btn-save {
    background: #2563eb;
    color: #fff;
    padding: 6px 14px;
    font-size: 13px;
}
.btn-save:hover { background: #1d4ed8; }

.link-actions {
    display: flex;
    gap: 8px;
}

.btn-scan {
    background: #059669;
    color: #fff;
    padding: 8px 16px;
}
.btn-scan:hover { background: #047857; }
.btn-scan:disabled { background: #9ca3af; cursor: wait; }

.btn-listings {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
}
.btn-listings:hover { background: #f9fafb; }

.btn-edit {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
}
.btn-edit:hover { background: #f9fafb; }
.btn-edit.saving {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.btn-edit.saving:hover { background: #1d4ed8; }

.edit-name-input, .edit-url-input {
    width: 100%;
    padding: 6px 10px;
    border: 2px solid #2563eb;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.edit-name-input {
    font-size: 18px;
    font-weight: 600;
}

.btn-delete {
    background: #ef4444;
    color: #fff;
    padding: 8px 16px;
}
.btn-delete:hover { background: #dc2626; }

.scan-result {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f0fdf4;
    border-radius: 4px;
    font-size: 13px;
    color: #166534;
}

.scan-result.error {
    background: #fef2f2;
    color: #991b1b;
}

.scan-result.scanning {
    background: #eff6ff;
    color: #1d4ed8;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Notified listings after scan */
.notified-header {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #059669;
}

.notified-header.below {
    margin-top: 14px;
    color: #2563eb;
}

.notified-listings {
    margin-top: 4px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.notified-listings.new {
    border-color: #a7f3d0;
}

.notified-listings.below {
    border-color: #bfdbfe;
}

.notified-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

.notified-item:last-child { border-bottom: none; }

.notified-main {
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.notified-price {
    font-weight: 700;
    font-size: 15px;
    color: #059669;
}

.notified-address {
    color: #374151;
    font-weight: 500;
}

.notified-details {
    color: #6b7280;
    font-size: 12px;
    margin-top: 2px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

#modal-body {
    padding: 20px;
    overflow-y: auto;
}

.listing-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
}

.listing-row:last-child { border-bottom: none; }

.listing-address { font-weight: 500; }
.listing-details { color: #6b7280; font-size: 13px; }
.listing-price { font-weight: 600; white-space: nowrap; }
.listing-ppsm { font-size: 13px; color: #2563eb; }

.listing-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 13px;
}
.listing-link:hover { text-decoration: underline; }

.empty-state {
    text-align: center;
    color: #9ca3af;
    padding: 40px;
    font-size: 14px;
}
