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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3348;
    --text: #e1e4ed;
    --text2: #8b90a5;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo { font-size: 1.2rem; font-weight: 700; color: var(--text); text-decoration: none; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: var(--text2); text-decoration: none; font-size: 0.9rem; padding: 4px 8px; border-radius: var(--radius); }
.nav-links a:hover { color: var(--text); background: var(--surface2); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }

h1 { font-size: 1.6rem; margin-bottom: 16px; }
h2 { font-size: 1.2rem; margin: 24px 0 12px; color: var(--text2); }

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

.status-bar { margin-bottom: 16px; }
.status-indicator { font-size: 0.85rem; padding: 4px 12px; border-radius: 20px; background: var(--surface2); }
.status-indicator.ok { color: var(--success); }
.status-indicator.bad { color: var(--danger); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.85rem; color: var(--text2); margin-top: 4px; }

.quick-actions { display: flex; gap: 12px; margin-bottom: 24px; }

.btn {
    display: inline-block; padding: 8px 16px; border-radius: var(--radius); font-size: 0.9rem;
    text-decoration: none; cursor: pointer; border: 1px solid var(--border);
    background: var(--surface2); color: var(--text); transition: all 0.15s;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text2); font-weight: 600; background: var(--surface); }
tr:hover { background: var(--surface2); }
td.actions { white-space: nowrap; }
td.actions form { display: inline; }
td.preview { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }

.badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 12px; font-weight: 600; text-transform: uppercase; }
.badge-completed, .badge-sent { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.badge-failed { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.badge-running, .badge-pending { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.badge-contacted { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); font-size: 0.8rem; padding: 4px 10px; border-radius: var(--radius); }
.badge-seller { font-size: 0.7rem; margin-left: 6px; background: var(--surface2); color: var(--text2); }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; background: var(--surface); }
legend { font-size: 0.85rem; font-weight: 600; color: var(--text2); padding: 0 8px; }
label { display: block; font-size: 0.85rem; color: var(--text2); margin-bottom: 4px; }
label input, label select, label textarea { margin-top: 4px; }

input, select, textarea {
    width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 0.9rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input[type="checkbox"] { width: auto; margin-right: 8px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-actions { display: flex; gap: 12px; margin-top: 16px; }

.help { font-size: 0.8rem; color: var(--text2); margin-top: 8px; }
.help code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; }
.error { color: var(--danger); font-size: 0.9rem; }
.empty { color: var(--text2); padding: 32px 0; text-align: center; }

.run-meta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.run-meta p { margin-bottom: 4px; font-size: 0.9rem; }

.batch-actions { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; }
.batch-actions select { width: auto; min-width: 200px; }
.batch-actions form { display: flex; gap: 12px; align-items: center; }

.listings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.listing-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: border-color 0.15s; }
.listing-card:hover { border-color: var(--primary); }
.listing-card.contacted { opacity: 0.8; }
.listing-card img { width: 100%; height: 200px; object-fit: cover; background: var(--surface2); }
.listing-info { padding: 16px; }
.listing-info h3 { font-size: 1rem; margin-bottom: 8px; }
.listing-meta { display: flex; gap: 12px; margin-bottom: 8px; font-size: 0.9rem; }
.listing-meta .price { font-weight: 700; color: var(--success); }
.listing-specs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.listing-specs span { font-size: 0.75rem; background: var(--surface2); padding: 2px 8px; border-radius: 12px; color: var(--text2); }
.listing-location { font-size: 0.85rem; color: var(--text2); margin-bottom: 4px; }
.listing-seller { font-size: 0.85rem; margin-bottom: 12px; }
.listing-actions { display: flex; gap: 8px; align-items: center; }

.message-result { padding: 16px; border-radius: var(--radius); margin: 16px 0; }
.message-result.success { background: color-mix(in srgb, var(--success) 15%, transparent); border: 1px solid var(--success); }
.message-result.error { background: color-mix(in srgb, var(--danger) 15%, transparent); border: 1px solid var(--danger); }

.batch-result { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 16px 0; }

.schedule-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
