:root {
    --bg: #0f1117;
    --bg2: #1a1d27;
    --bg3: #252830;
    --text: #e1e4ea;
    --text-muted: #8b8fa3;
    --primary: #4f8ff7;
    --primary-hover: #3a7be0;
    --success: #34c759;
    --warn: #ff9f0a;
    --error: #ff453a;
    --border: #2c2f3a;
    --radius: 8px;
}

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

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

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
}
.nav-brand { font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; gap: 0.5rem; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
}
.nav-links a:hover { color: var(--text); background: var(--bg3); }
.nav-links a.active { color: var(--primary); background: rgba(79, 143, 247, 0.1); }
.nav-session {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.session-indicator {
    font-size: 0.8rem;
    padding: 0.25rem 0.7rem;
    border-radius: 12px;
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
    border: 1px solid rgba(52, 199, 89, 0.3);
    font-weight: 600;
}
.nav-user-name { font-size: 0.8rem; color: var(--text); font-weight: 500; margin-left: 0.5rem; }
.nav-logout { margin-left: 0.25rem; display: inline-flex; }
.btn-logout { color: var(--error); border-color: rgba(255, 69, 58, 0.3); }
.btn-logout:hover { background: rgba(255, 69, 58, 0.15); }

/* Container */
.container { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }

h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 0.5rem; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.card h3 { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.card p { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.card.ok { border-left: 3px solid var(--success); }
.card.warn { border-left: 3px solid var(--warn); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg3);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    text-decoration: none;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #000; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; }
tbody tr:hover { background: var(--bg2); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg3);
    color: var(--text-muted);
}
.badge-running { background: rgba(79, 143, 247, 0.2); color: var(--primary); }
.badge-completed { background: rgba(52, 199, 89, 0.2); color: var(--success); }
.badge-error { background: rgba(255, 69, 58, 0.2); color: var(--error); }
.badge-paused { background: rgba(255, 159, 10, 0.2); color: var(--warn); }
.badge-pending { background: var(--bg3); color: var(--text-muted); }

/* Progress bar */
.progress-bar {
    position: relative;
    height: 28px;
    background: var(--bg3);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 0.5rem 0;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #6aa3f9);
    border-radius: var(--radius);
    transition: width 0.5s ease;
}
.progress-bar span {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Forms */
.input-group { display: flex; gap: 0.5rem; margin: 0.5rem 0; }
.input-group input, .input-group select {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg3);
    color: var(--text);
    font-size: 0.9rem;
}
.input-full {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg3);
    color: var(--text);
    font-size: 0.85rem;
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* Messages */
.message { font-size: 0.85rem; padding: 0.25rem 0; min-height: 1.2em; }
.message.success { color: var(--success); }
.message.error { color: var(--error); }
.message.warn { color: var(--warn); }

/* Status indicators */
.status-ok { color: var(--success); font-weight: 600; }
.status-ok::before { content: "✓ "; }
.status-warn { color: var(--warn); }
.status-warn::before { content: "⚠ "; }

/* Setup */
.setup-section {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.setup-guide {
    background: var(--bg3);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
}
.setup-guide ol { padding-left: 1.25rem; }
.setup-guide li { margin: 0.3rem 0; font-size: 0.9rem; }
.setup-guide ul { padding-left: 1rem; margin: 0.25rem 0; }
.help-text { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; }
.role-line { display: flex; align-items: center; gap: 0.4rem; margin: 2px 0; }
.role-line .text-muted { font-size: 0.8rem; }
code {
    background: var(--bg3);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
}
a { color: var(--primary); }

/* Migration cards */
.channel-list { display: flex; flex-direction: column; gap: 1rem; }
.migration-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.migration-header { display: flex; justify-content: space-between; align-items: center; }
.migration-header h3 { margin: 0; }
.migration-footer { margin-top: 0.75rem; display: flex; gap: 0.5rem; }
.status-text { font-size: 0.85rem; margin-top: 0.25rem; }
.error-text { color: var(--error); margin-left: 0.5rem; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; margin-left: 0.5rem; }

/* Logs */
.migration-logs { margin-top: 1rem; }
.log-container {
    background: #0a0c10;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}
.log-line { padding: 1px 0; }
.log-info { color: var(--text-muted); }
.log-warn { color: var(--warn); }
.log-error { color: var(--error); }

/* Message Preview */
.migration-preview { margin-top: 1rem; }
.preview-container {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
}
.preview-legend {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.preview-msg {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(44, 47, 58, 0.5);
}
.preview-msg:last-child { border-bottom: none; }
.preview-msg-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}
.preview-sender-mapped { font-weight: 600; color: var(--success); font-size: 0.85rem; }
.preview-sender-unmapped { font-weight: 600; color: var(--warn); font-size: 0.85rem; }
.preview-date { color: var(--text-muted); font-size: 0.75rem; margin-left: auto; }
.preview-msg-body { margin-left: 0.25rem; }
.preview-meta { font-size: 0.8rem; color: var(--text-muted); font-style: italic; margin-bottom: 0.2rem; }
.preview-text { font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; }
.preview-media { font-size: 0.8rem; color: var(--primary); margin-top: 0.2rem; }
.preview-gchat-box {
    margin-top: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.82rem;
}
.preview-gchat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.preview-gchat-content { line-height: 1.5; }
.preview-gchat-sender { color: var(--primary); font-weight: 600; }
.preview-drive-link { color: var(--primary); font-size: 0.8rem; text-decoration: none; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state h2 { color: var(--text); margin-bottom: 0.5rem; }
.steps {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2rem;
}
.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.step-num {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg3);
    border: 2px solid var(--border);
    font-weight: 700;
}
.step.done .step-num { border-color: var(--success); color: var(--success); }
