/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
       font-size: 14px; color: #333; background: #f0f2f5; }
a { color: #3b82f6; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px; min-width: 200px;
  background: #1e293b; color: #cbd5e1;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; z-index: 10;
}
.sidebar-logo { padding: 1.2rem 1rem; font-size: 1.4rem; font-weight: 700;
                color: #fff; border-bottom: 1px solid #334155; }
.sidebar-logo a { color: #fff; }
.sidebar-nav { flex: 1; padding: 0.5rem 0; }
.nav-item { display: flex; align-items: center; gap: 0.5rem;
            padding: 0.6rem 1rem; color: #94a3b8;
            transition: background 0.15s; cursor: pointer; }
.nav-item:hover { background: #334155; color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: #3b82f6; color: #fff; }
.nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }
.sidebar-footer { padding: 0.8rem 1rem; border-top: 1px solid #334155; }
.logout-btn { color: #94a3b8; font-size: 0.85rem; }

.main-content {
  margin-left: 200px; flex: 1;
  padding: 1.5rem; min-height: 100vh;
}

/* ── Page Header ──────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 1.2rem; }
.page-title { font-size: 1.4rem; font-weight: 700; color: #1e293b; }

/* ── Cards ────────────────────────────────────────── */
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1);
        margin-bottom: 1rem; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between;
               padding: 0.8rem 1rem; border-bottom: 1px solid #e2e8f0; }
.card-title { font-size: 1rem; font-weight: 600; color: #1e293b; }
.card-body { padding: 1rem; }
.card-link { font-size: 0.85rem; color: #3b82f6; }

/* ── Stats ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: #fff; border-radius: 8px; padding: 1rem 1.2rem;
             box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.stat-card.stat-warn { border-left: 4px solid #ef4444; }
.stat-label { font-size: 0.8rem; color: #64748b; margin-bottom: 0.3rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: #1e293b; line-height: 1; }
.stat-sub { font-size: 0.75rem; color: #94a3b8; margin-top: 0.3rem; }

.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ── Tables ───────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { background: #f8fafc; padding: 0.6rem 0.8rem; text-align: left;
            font-weight: 600; color: #475569; border-bottom: 2px solid #e2e8f0; }
.table td { padding: 0.6rem 0.8rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.row-warn td { background: #fff5f5; }
.row-info td { background: #eff6ff; }
.empty-msg { text-align: center; color: #94a3b8; padding: 2rem; }
.actions { white-space: nowrap; }
.preview-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-cell { color: #ef4444; font-size: 0.8rem; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* ── Badges ───────────────────────────────────────── */
.badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px;
         font-size: 0.75rem; font-weight: 600; }
.badge-tier1 { background: #dbeafe; color: #1d4ed8; }
.badge-tier2 { background: #fef3c7; color: #92400e; }
.badge-tier3 { background: #fce7f3; color: #9d174d; }
.badge-status-draft    { background: #f1f5f9; color: #475569; }
.badge-status-reviewing { background: #fef3c7; color: #92400e; }
.badge-status-approved  { background: #d1fae5; color: #065f46; }
.badge-status-published { background: #dbeafe; color: #1d4ed8; }
.badge-status-rejected  { background: #fee2e2; color: #991b1b; }
.badge-status-active   { background: #d1fae5; color: #065f46; }
.badge-status-done     { background: #dbeafe; color: #1d4ed8; }
.badge-status-paused   { background: #f1f5f9; color: #475569; }
.badge-status-pending  { background: #fef3c7; color: #92400e; }
.badge-status-running  { background: #bfdbfe; color: #1e40af; }
.badge-status-failed   { background: #fee2e2; color: #991b1b; }
.badge-status-cancelled { background: #f1f5f9; color: #475569; }
.badge-platform-x       { background: #1e293b; color: #fff; }
.badge-platform-x_thread{ background: #334155; color: #fff; }
.badge-platform-tiktok  { background: #fce7f3; color: #9d174d; }
.badge-platform-instagram{ background: #fef3c7; color: #92400e; }
.badge-platform-line    { background: #d1fae5; color: #065f46; }
.badge-primary { background: #3b82f6; color: #fff; }
.badge-default { background: #e2e8f0; color: #475569; }

/* ── Buttons ──────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center;
       padding: 0.4rem 0.9rem; border-radius: 6px; border: none; cursor: pointer;
       font-size: 0.875rem; font-weight: 500; text-decoration: none;
       transition: opacity 0.15s; white-space: nowrap; }
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-primary   { background: #3b82f6; color: #fff; }
.btn-success   { background: #10b981; color: #fff; }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-xs { padding: 0.15rem 0.5rem; font-size: 0.75rem; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ── Forms ────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-weight: 600; margin-bottom: 0.3rem; color: #374151; font-size: 0.875rem; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 0.875rem; color: #374151;
  background: #fff; transition: border-color 0.15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.form-hint { color: #6b7280; font-size: 0.78rem; margin-top: 0.25rem; display: block; }
.form-row { display: flex; gap: 1rem; }
.form-row .half { flex: 1; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; }
.required { color: #ef4444; }

/* ── Flash messages ───────────────────────────────── */
.flash { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.875rem; }
.flash-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.flash-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.flash-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ── Filter bar ───────────────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; align-items: center; }
.filter-btn { padding: 0.3rem 0.7rem; border-radius: 20px; font-size: 0.8rem;
              background: #e2e8f0; color: #475569; }
.filter-btn.active { background: #3b82f6; color: #fff; }
.filter-btn:hover { text-decoration: none; opacity: 0.85; }
.filter-sep { color: #cbd5e1; }

/* ── Login ────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: #1e293b; }
.login-box { background: #fff; padding: 2.5rem; border-radius: 12px;
             box-shadow: 0 10px 40px rgba(0,0,0,.3); width: 340px; }
.login-title { font-size: 2rem; font-weight: 700; color: #1e293b; text-align: center; margin-bottom: 0.3rem; }
.login-sub { color: #64748b; text-align: center; margin-bottom: 1.5rem; font-size: 0.85rem; }

/* ── Article detail ───────────────────────────────── */
.article-meta-bar { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center;
                    margin-bottom: 1rem; font-size: 0.875rem; }
.article-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.article-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; }
.article-body { font-size: 0.95rem; line-height: 1.8; }
.article-body h1, .article-body h2, .article-body h3 { margin: 1rem 0 0.5rem; }
.article-body p { margin-bottom: 0.8rem; }
.article-body ul, .article-body ol { margin: 0.5rem 0 0.8rem 1.5rem; }
.md-source { font-size: 0.78rem; white-space: pre-wrap; max-height: 300px; overflow-y: auto;
             background: #f8fafc; padding: 0.8rem; border-radius: 4px; color: #475569; }

/* ── SNS ──────────────────────────────────────────── */
.sns-item { padding: 0.6rem 0; border-bottom: 1px solid #f1f5f9; }
.sns-platform { display: flex; gap: 0.4rem; align-items: center; margin-bottom: 0.3rem; }
.sns-preview { font-size: 0.8rem; color: #64748b; }
.sns-editor { font-family: monospace; font-size: 0.875rem; }
.cluster-meta { display: flex; gap: 1.5rem; flex-wrap: wrap; }

/* ── Tier bars ────────────────────────────────────── */
.tier-bars { display: flex; flex-direction: column; gap: 0.6rem; }
.tier-bar-row { display: flex; align-items: center; gap: 0.5rem; }
.tier-label { width: 130px; font-size: 0.8rem; }
.tier-bar-bg { flex: 1; height: 10px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.tier-bar { height: 100%; border-radius: 5px; transition: width 0.5s; }
.tier-bar-tier1 { background: #3b82f6; }
.tier-bar-tier2 { background: #f59e0b; }
.tier-bar-tier3 { background: #ec4899; }
.tier-count { font-size: 0.8rem; color: #475569; width: 30px; text-align: right; }

/* ── Quick actions ────────────────────────────────── */
.quick-actions { display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Code block ───────────────────────────────────── */
.code-block { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 6px;
              font-family: monospace; font-size: 0.8rem; white-space: pre-wrap; overflow-x: auto; }
