* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f5; color: #333; font-size: 14px; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.nav { background: #1e293b; color: #fff; padding: 12px 24px; display: flex; align-items: center; gap: 24px; position: sticky; top: 0; z-index: 100; flex-wrap: wrap; }
.nav h1 { font-size: 18px; font-weight: 700; margin-right: 16px; }
.nav a { color: #94a3b8; font-size: 14px; padding: 6px 12px; border-radius: 6px; }
.nav a:hover, .nav a.active { color: #fff; background: #334155; text-decoration: none; }
.nav .stats-bar { margin-left: auto; font-size: 12px; color: #94a3b8; display: flex; gap: 16px; flex-wrap: wrap; }
.stats-bar span { background: #334155; padding: 4px 8px; border-radius: 4px; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 16px; border: 1px solid #ddd; background: #fff; border-radius: 6px 6px 0 0; cursor: pointer; font-size: 13px; }
.tab:hover { background: #e2e8f0; }
.tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.tab .badge { font-size: 11px; background: rgba(0,0,0,0.15); padding: 1px 6px; border-radius: 10px; margin-left: 4px; }

/* Filters */
.filters { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input, .filters button {
  padding: 6px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px;
}
.filters button { background: #2563eb; color: #fff; border: none; cursor: pointer; }
.filters button:hover { background: #1d4ed8; }

/* Cards */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card-keyword { font-weight: 700; font-size: 15px; color: #1e293b; }
.card-cluster { font-size: 12px; color: #64748b; margin-top: 2px; }
.card-relevance { background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.card-target { font-size: 13px; margin: 8px 0; word-break: break-all; }
.card-target a { color: #2563eb; }

.card textarea {
  width: 100%; min-height: 80px; padding: 10px; border: 1px solid #e2e8f0;
  border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical;
  line-height: 1.5;
}
.card textarea:focus { border-color: #2563eb; outline: none; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }

.card-utm { font-size: 12px; color: #64748b; margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.card-utm-row { display: flex; align-items: center; gap: 8px; }
.card-utm-row code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 11px; max-width: 500px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn { background: none; border: 1px solid #cbd5e1; padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; color: #64748b; }
.copy-btn:hover { background: #f1f5f9; }

.card-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.card-actions button { padding: 6px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; border: 1px solid #ddd; background: #fff; }
.btn-copy { background: #f0f9ff; border-color: #bae6fd; color: #0369a1; }
.btn-copy:hover { background: #e0f2fe; }
.btn-open { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.btn-open:hover { background: #dcfce7; }
.btn-done { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-done:hover { background: #1d4ed8; }
.btn-skip { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
.btn-skip:hover { background: #fee2e2; }
.btn-generate { background: #faf5ff; border-color: #d8b4fe; color: #7c3aed; font-weight: 600; }
.btn-generate:hover { background: #f3e8ff; }
.btn-generate.loading { opacity: 0.6; cursor: wait; }

.card-meta { font-size: 11px; color: #94a3b8; margin-left: auto; }
.card.status-posted { opacity: 0.6; border-left: 3px solid #22c55e; }
.card.status-skipped { opacity: 0.5; border-left: 3px solid #ef4444; }
.card.status-ready { border-left: 3px solid #f59e0b; }

/* Version Tabs */
.version-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.version-tab { padding: 4px 12px; border: 1px solid #e2e8f0; background: #f8fafc; border-radius: 6px 6px 0 0; cursor: pointer; font-size: 12px; color: #64748b; }
.version-tab:hover { background: #e2e8f0; }
.version-tab.active { background: #7c3aed; color: #fff; border-color: #7c3aed; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: #1e293b; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 999; opacity: 0; transition: opacity 0.3s; }
.toast.show { opacity: 1; }

/* Keywords page */
.kw-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.kw-table th, .kw-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.kw-table th { background: #f8fafc; font-weight: 600; position: sticky; top: 56px; z-index: 10; }
.kw-table tr:hover { background: #f8fafc; }
.kw-table input[type="number"] { width: 50px; padding: 2px 4px; border: 1px solid #e2e8f0; border-radius: 4px; text-align: center; }

/* UTM page */
.utm-form { background: #fff; padding: 16px; border-radius: 8px; margin-bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.utm-form label { font-size: 12px; font-weight: 600; display: block; margin-bottom: 2px; }
.utm-form input, .utm-form select { padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }
.utm-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.utm-table th, .utm-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.utm-table th { background: #f8fafc; font-weight: 600; }

/* Analytics */
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.analytics-card { background: #fff; border-radius: 8px; padding: 16px; }
.analytics-card h3 { font-size: 14px; margin-bottom: 12px; }

/* Empty state */
.empty { text-align: center; padding: 48px; color: #94a3b8; }

/* New promo form */
.new-promo-form { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 16px; display: none; }
.new-promo-form.show { display: block; }
.new-promo-form .form-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.new-promo-form select, .new-promo-form input { padding: 6px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }
.new-promo-form textarea { width: 100%; min-height: 60px; padding: 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; margin-bottom: 8px; }

/* Pipeline page */
.pipeline-controls { display: flex; gap: 12px; margin-bottom: 20px; }
.btn-pipeline { padding: 12px 28px; background: #7c3aed; color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn-pipeline:hover { background: #6d28d9; }
.btn-pipeline:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-refresh { padding: 12px 20px; background: #fff; color: #334155; border: 1px solid #ddd; border-radius: 8px; font-size: 13px; cursor: pointer; }
.btn-refresh:hover { background: #f8fafc; }

.pipeline-status { background: #fff; border-radius: 8px; padding: 20px; }
.pipeline-info { display: flex; flex-direction: column; gap: 8px; }
.pipeline-row { font-size: 14px; }
.pipeline-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-running { background: #fef3c7; color: #92400e; }
.badge-idle { background: #d1fae5; color: #065f46; }

.pipeline-log { margin-top: 16px; }
.pipeline-log pre { background: #1e293b; color: #e2e8f0; padding: 16px; border-radius: 8px; font-size: 12px; line-height: 1.6; overflow-x: auto; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin-top: 8px; }

/* ========== Karma Page ========== */
.karma-controls { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.karma-controls select { padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }

.karma-status-bar { background: #f8fafc; padding: 8px 16px; border-radius: 6px; font-size: 12px; color: #64748b; margin-bottom: 8px; }

.karma-card .card-header { gap: 12px; }
.karma-score { display: inline-block; background: #fef3c7; color: #92400e; padding: 2px 10px; border-radius: 12px; font-size: 14px; font-weight: 700; }

.karma-draft { min-height: 60px !important; background: #f8fafc; }

/* ========== Accounts Page ========== */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }

.account-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; }
.account-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #f1f5f9; }
.account-codename { font-weight: 700; font-size: 16px; color: #1e293b; }
.account-username { font-size: 12px; color: #64748b; margin-left: 8px; }
.account-role { color: #fff; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; }

.account-info { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.account-row { font-size: 13px; line-height: 1.6; }
.account-row strong { color: #475569; }

.karma-bar { display: inline-block; width: 120px; height: 8px; background: #e2e8f0; border-radius: 4px; vertical-align: middle; margin-left: 8px; overflow: hidden; }
.karma-fill { height: 100%; background: #22c55e; border-radius: 4px; transition: width 0.3s; }

.sub-tag { display: inline-block; background: #f0f9ff; color: #0369a1; padding: 1px 6px; border-radius: 4px; font-size: 11px; margin: 1px; }

.account-today { display: flex; gap: 16px; padding: 8px 0; border-top: 1px solid #f1f5f9; font-size: 12px; color: #64748b; margin-bottom: 8px; }

.account-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.account-actions input { padding: 4px 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.account-actions select { padding: 4px 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 12px; }
.account-actions button { padding: 4px 10px; font-size: 12px; }
