:root {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --primary: #58a6ff;
    --green: #3fb950;
    --orange: #d29922;
    --red: #f85149;
    --purple: #bc8cff;
    --blue: #58a6ff;
    --gray: #8b949e;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--text-muted); font-size: 0.875rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* Stats */
.stats-bar {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

/* Filters */
.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filters select, .filters input, .filters button {
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
}

.filters button {
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.filters button:hover { opacity: 0.9; }

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

tbody tr { cursor: pointer; transition: background 0.15s; }
tbody tr:hover { background: rgba(88, 166, 255, 0.05); }
tbody td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
tbody tr:last-child td { border-bottom: none; }

.post-title a { color: var(--text); font-weight: 500; }
.post-title a:hover { color: var(--primary); }

/* Score */
.score {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.8rem;
    min-width: 2.5rem;
    text-align: center;
}

.score-green { background: rgba(63, 185, 80, 0.15); color: var(--green); }
.score-orange { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.score-red { background: rgba(248, 81, 73, 0.15); color: var(--red); }
.score-gray { background: rgba(139, 148, 158, 0.15); color: var(--gray); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-blue { background: rgba(88, 166, 255, 0.15); color: var(--blue); }
.badge-gray { background: rgba(139, 148, 158, 0.15); color: var(--gray); }
.badge-orange { background: rgba(210, 153, 34, 0.15); color: var(--orange); }
.badge-purple { background: rgba(188, 140, 255, 0.15); color: var(--purple); }
.badge-green { background: rgba(63, 185, 80, 0.15); color: var(--green); }

.topic {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.date { color: var(--text-muted); white-space: nowrap; }
.empty { text-align: center; color: var(--text-muted); padding: 2rem; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Post detail */
.post-detail { max-width: 800px; }

.post-header { margin-bottom: 1.5rem; }
.post-header h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.post-meta { display: flex; gap: 1rem; color: var(--text-muted); font-size: 0.875rem; flex-wrap: wrap; }

.post-scores {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.score-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

.summary, .post-body, .reply-draft, .replies {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.summary h3, .post-body h3, .reply-draft h3, .replies h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.body-text { white-space: pre-wrap; word-break: break-word; font-size: 0.875rem; }

pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.875rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Actions */
.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.status-buttons { display: flex; gap: 0.5rem; }

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
}

.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-gray { color: var(--gray); }
.btn-orange { color: var(--orange); }
.btn-purple { color: var(--purple); }

/* Sources */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.source-card {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.source-card.disabled { opacity: 0.5; }
.source-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.source-meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text-muted); }

/* Settings */
.settings-section { margin-bottom: 2rem; }
.settings-section h2 { margin-bottom: 1rem; font-size: 1.25rem; }

.criteria-list { display: grid; gap: 0.75rem; }
.criteria-card {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.criteria-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.criteria-card p { font-size: 0.875rem; color: var(--text-muted); }
.weight { font-size: 0.8rem; color: var(--orange); }

/* Responsive */
@media (max-width: 768px) {
    .stats-bar { flex-direction: column; }
    .filters { flex-direction: column; }
    .post-actions { flex-direction: column; gap: 0.75rem; }
    .post-scores { flex-wrap: wrap; }
}

/* Auth pages */
.auth-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
}
.auth-container h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
    color: var(--primary);
}
.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}
.auth-form {
    text-align: left;
}
.auth-form .form-group {
    margin-bottom: 1rem;
}
.auth-form label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.auth-form input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 1rem;
    box-sizing: border-box;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}
.auth-form .btn-primary {
    width: 100%;
    margin-top: 0.5rem;
}
.auth-link {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.auth-link a {
    color: var(--primary);
}
.alert-error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* Profiles */
.profiles-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.profiles-grid { display: grid; gap: 1rem; }
.profile-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.profile-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.profile-card-header h3 { margin: 0; }
.profile-card-header h3 a { color: var(--text); text-decoration: none; }
.profile-card-header h3 a:hover { color: var(--primary); }
.profile-card-meta { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 0.5rem; }
.profile-tone { color: var(--text-muted); font-size: 0.8rem; font-style: italic; margin: 0.5rem 0; }
.profile-card-actions { margin-top: 0.75rem; }
.profile-form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.profile-form legend { color: var(--text-muted); font-size: 0.875rem; padding: 0 0.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; color: var(--text-muted); font-size: 0.875rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.5rem; background: var(--bg); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text); font-size: 0.9rem; box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.5rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { accent-color: var(--primary); }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.btn { display: inline-block; padding: 0.5rem 1rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text); text-decoration: none; font-size: 0.875rem; cursor: pointer; }
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); color: #000; border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { opacity: 0.9; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.sep { color: var(--border); }

/* Post cards (dashboard supervision) */
.posts-list { display: grid; gap: 0.75rem; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.post-card-header { display: flex; gap: 0.75rem; align-items: flex-start; }
.post-card-header .score { font-size: 1.1rem; font-weight: 700; min-width: 2.5rem; text-align: center; }
.post-card-title { flex: 1; }
.post-card-title a { color: var(--text); text-decoration: none; font-weight: 500; }
.post-card-title a:hover { color: var(--primary); }
.post-card-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.25rem; font-size: 0.8rem; color: var(--text-muted); }
.post-card-draft { margin-top: 0.75rem; padding: 0.75rem; background: var(--bg); border-radius: 4px; border-left: 3px solid var(--primary); }
.draft-label { font-size: 0.75rem; color: var(--primary); margin-bottom: 0.25rem; font-weight: 600; }
.draft-text { font-size: 0.85rem; color: var(--text); white-space: pre-wrap; line-height: 1.5; }
.post-card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.btn-action { border-color: var(--text-muted); color: var(--text-muted); }
.btn-action:hover { border-color: var(--primary); color: var(--primary); }
