/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0f1117;
    --surface:   #1a1d27;
    --surface2:  #22263a;
    --border:    #2e3250;
    --accent:    #4f7cff;
    --accent-h:  #6a93ff;
    --green:     #22c55e;
    --red:       #ef4444;
    --gray:      #6b7280;
    --text:      #e2e8f0;
    --text-dim:  #94a3b8;
    --radius:    10px;
    --shadow:    0 4px 24px rgba(0,0,0,.45);
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); text-decoration: underline; }

/* ── Layout ──────────────────────────────────────────────────────── */
.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.logo { font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.subtitle { color: var(--text-dim); font-size: 13px; }

.container {
    max-width: 1600px;
    margin: 32px auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Card ────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.card h3 { font-size: 14px; font-weight: 600; color: var(--text-dim);
           text-transform: uppercase; letter-spacing: .6px;
           margin: 20px 0 10px; }

/* ── Input ───────────────────────────────────────────────────────── */
.hint { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }

.raw-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.55;
    padding: 14px;
    resize: vertical;
    transition: border-color .2s;
}
.raw-input:focus { outline: none; border-color: var(--accent); }

.form-actions { display: flex; gap: 10px; margin-top: 14px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: background .2s, transform .1s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-primary:active:not(:disabled) { transform: scale(.97); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 10px 18px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }

/* ── Result card tints ───────────────────────────────────────────── */
.result-success { border-color: #1e4033; }
.result-error   { border-color: #4b1c1c; }

/* ── Log ─────────────────────────────────────────────────────────── */
.log-panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}
.log-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.log-list li::before { content: "▸ "; color: var(--accent); }
.log-list li { font-size: 13px; color: var(--text-dim); }
.log-list li strong { color: var(--text); }

/* ── Fields grid ─────────────────────────────────────────────────── */
.fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.field {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
}
.field.field-wide { grid-column: 1 / -1; }
.field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.field span { font-size: 14px; color: var(--text); word-break: break-word; }

/* ── Badge ───────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.badge-green { background: rgba(34,197,94,.15); color: var(--green); }
.badge-red   { background: rgba(239,68,68,.15);  color: var(--red);  }
.badge-gray  { background: rgba(107,114,128,.15); color: var(--gray); }

/* ── Leads table ─────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }

.leads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.leads-table th {
    background: var(--surface2);
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
}
.leads-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.leads-table tr:last-child td { border-bottom: none; }
.leads-table tr:hover td { background: var(--surface2); }

.name-cell {
    font-weight: 600;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}
.date-cell { color: var(--text-dim); white-space: nowrap; }

.remarks-cell {
    color: var(--text-dim);
    font-size: 12px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

.remarks-field span {
    color: #f59e0b;
    font-size: 13px;
}

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Top Nav ─────────────────────────────────────────────────────── */
.top-nav { margin-left: auto; display: flex; gap: 4px; }
.nav-link {
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 6px;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.nav-link:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }

/* ── Search form ─────────────────────────────────────────────────── */
.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 4px;
}
.search-field { display: flex; flex-direction: column; gap: 5px; }
.search-field-wide { grid-column: 1 / -1; }
.search-field label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-dim);
}
.form-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    padding: 9px 12px;
    width: 100%;
    transition: border-color .2s;
    font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--accent); }
select.form-input { cursor: pointer; }
select.form-input option { background: var(--surface); }
.rating-range { display: flex; align-items: center; gap: 8px; }
.rating-input { flex: 1; }
.range-sep { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.score-cell { font-weight: 600; color: var(--accent); white-space: nowrap; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .container { padding: 0 12px; margin: 16px auto; }
    .card { padding: 18px 16px; }
    .fields-grid { grid-template-columns: 1fr; }
}
