/* ═══════════════════════════════════════════════════════════
   ARTICULUS CMS — Design System v2
   Light theme · Sky Blue accent · Linear-inspired
   ═══════════════════════════════════════════════════════════ */

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

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Surface */
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --bg4: #e2e8f0;

  /* Border */
  --border: #e2e8f0;
  --border-med: #cbd5e1;
  --border-str: #94a3b8;

  /* Text */
  --text: #0f172a;
  --text-2: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Brand — Sky Blue from screenshots */
  --primary: #0369a1;
  --primary-light: #0ea5e9;
  --primary-hover: #075985;
  --primary-dim: #e0f2fe;
  --primary-mid: #bae6fd;
  --primary-ring: rgba(3, 105, 161, 0.2);

  /* Semantic */
  --success: #16a34a;
  --success-dim: rgba(22, 163, 74, 0.08);
  --success-ring: rgba(22, 163, 74, 0.2);
  --warning: #d97706;
  --warning-dim: rgba(217, 119, 6, 0.08);
  --error: #dc2626;
  --error-dim: rgba(220, 38, 38, 0.08);

  /* Shape */
  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.05);

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Base ───────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

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

/* ═══════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════ */
.app-header {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 24px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 26px;
  height: 26px;
  background: var(--text);
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  flex-shrink: 0;
}

.brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

/* Divider between brand and nav */
.brand::after {
  content: '';
  display: block;
  width: 1px;
  height: 20px;
  background: var(--border-med);
  margin-left: 24px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  border: none;
  background: none;
  letter-spacing: -0.01em;
}

.nav-link svg {
  opacity: 0.6;
  transition: opacity 0.1s;
}

.nav-link:hover {
  background: var(--bg3);
  color: var(--text-2);
}

.nav-link:hover svg {
  opacity: 0.9;
}

.nav-link.active {
  background: var(--bg3);
  color: var(--text);
  font-weight: 600;
}

.nav-link.active svg {
  opacity: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 3px 8px 3px 4px;
  border-radius: var(--radius-sm);
}

.header-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-dim);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--primary-ring);
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */

/* Primary */
.btn-primary,
.btn-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--text);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, box-shadow 0.12s;
  white-space: nowrap;
  letter-spacing: -0.01em;
  font-family: var(--font);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover,
.btn-new:hover {
  background: var(--text-2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

.btn-primary:active,
.btn-new:active {
  background: #18181b;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary.loading .btn-text {
  opacity: 0;
}

.btn-primary.loading .loader-spinner {
  display: block;
}

/* Ghost */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg2);
  color: var(--text-2);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  white-space: nowrap;
  font-family: var(--font);
  letter-spacing: -0.01em;
}

.btn-ghost:hover {
  background: var(--bg3);
  border-color: var(--border-str);
  color: var(--text);
}

.btn-ghost:active {
  background: var(--bg4);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 0.775rem;
}

/* Icon button */
.btn-icon-round {
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  flex-shrink: 0;
}

.btn-icon-round:hover {
  background: var(--bg3);
  border-color: var(--border-med);
  color: var(--text);
}

/* Back button */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
  font-family: var(--font);
  letter-spacing: -0.01em;
}

.btn-back:hover {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border-med);
}

/* Loader */
.loader-spinner {
  display: none;
  width: 13px;
  height: 13px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  position: absolute;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ═══════════════════════════════════════════════════════════
   MAIN / VIEWS
   ═══════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 28px;
}

/* View header */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.view-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.view-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.view-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.view-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════
   TABLE  (Articles list)
   ═══════════════════════════════════════════════════════════ */
.table-wrapper {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.articles-table {
  width: 100%;
  border-collapse: collapse;
}

.articles-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}

.articles-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}

.articles-table tr:last-child td {
  border-bottom: none;
}

.articles-table tbody tr {
  transition: background 0.1s;
  cursor: pointer;
}

.articles-table tbody tr:hover td {
  background: var(--bg3);
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 64px 16px !important;
  font-size: 0.85rem;
}

/* ── Tasks filter bar ───────────────────────────────────────── */
.tasks-filter-bar {
  margin-bottom: 16px;
  padding: 12px 16px;
}

.tasks-filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.tasks-filter-search {
  flex: 1;
  width: auto !important;
}

.tasks-filter-select {
  width: auto !important;
}

.tasks-filter-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 0.01em;
}

/* Title cell */
.article-title-cell {
  font-weight: 500;
  color: var(--text);
  font-size: 0.875rem;
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

/* Keyword sub-line */
.article-kw-sub {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 460px;
}

.article-kw-cell {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-date-cell {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ── Status Pill ─────────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-pill.completed {
  background: rgba(2, 132, 199, 0.08);
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.18);
}

.status-pill.failed {
  background: rgba(220, 38, 38, 0.07);
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.18);
}

.status-pill.generating {
  background: rgba(217, 119, 6, 0.07);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.18);
}

.status-pill.pending {
  background: var(--bg3);
  color: var(--text-muted);
  border-color: var(--border-med);
}

.status-pill.duplicate {
  background: var(--bg3);
  color: var(--text-muted);
  border-color: var(--border-med);
}

.status-pill.publishing {
  background: rgba(99, 102, 241, 0.07);
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.18);
}

.status-pill.published {
  background: rgba(22, 163, 74, 0.07);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.18);
}

/* Status badge (used in detail header) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-badge.completed {
  color: #0284c7;
}

.status-badge.failed {
  color: #dc2626;
}

.status-badge.generating {
  color: #b45309;
}

.status-badge.pending {
  color: var(--text-muted);
}

.status-badge.duplicate {
  color: var(--text-muted);
}

.status-badge.publishing {
  color: #4f46e5;
}

.status-badge.published {
  color: #15803d;
}

/* ── Row actions ─────────────────────────────────────────────── */
.table-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.1s;
  justify-content: flex-end;
}

.articles-table tbody tr:hover .table-actions {
  opacity: 1;
}

.action-btn {
  width: 26px;
  height: 26px;
  background: var(--bg2);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.action-btn:hover {
  background: var(--bg3);
  border-color: var(--border-str);
  color: var(--text);
}

/* Delete action button — red accent */
.action-btn-delete {
  color: var(--text-light);
}

.action-btn-delete:hover {
  background: var(--error-dim);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--error);
}

.btn-icon-round.action-btn-delete:hover {
  background: var(--error-dim);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--error);
}

/* Delete button on detail page */
.btn-delete-detail {
  color: var(--error) !important;
  border-color: rgba(220, 38, 38, 0.25);
  margin-left: auto;
}

.btn-delete-detail:hover {
  background: var(--error-dim) !important;
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--error) !important;
}

/* ═══════════════════════════════════════════════════════════
   DETAIL VIEW — new Tabs + Sidebar layout
   ═══════════════════════════════════════════════════════════ */
.detail-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* Two-column grid: content | sidebar */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  height: 100%;
  overflow: hidden;
}

/* ── Left: tab content area ── */
.detail-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg2);
}

/* Topbar */
.detail-topbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.detail-topbar-main {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.detail-topbar-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-topbar-sub svg {
  opacity: 0.7;
}

.detail-title {
  font-size: 0.97rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

/* ── Tabs bar ── */
.tabs-bar {
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s;
  font-family: var(--font);
  letter-spacing: -0.01em;
  margin-bottom: -1px;
}

.tab-btn svg {
  opacity: 0.6;
  transition: opacity 0.1s;
}

.tab-btn:hover {
  color: var(--text-2);
}

.tab-btn:hover svg {
  opacity: 0.85;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-btn.active svg {
  opacity: 1;
}

/* ── Tab panels ── */
.tab-panels {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Right: sidebar ── */
.detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  background: var(--bg);
  padding: 14px;
}

/* Card component (like ESTIMATE / OUTPUT blocks from screenshot) */
.sidebar-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.sidebar-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  padding: 9px 14px;
  border-bottom: 1px solid var(--primary-mid);
  background: var(--primary-dim);
}

.sidebar-card-body {
  padding: 2px 0;
}

/* sb-row: key → value rows inside sidebar cards */
.sb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  min-height: 38px;
}

.sb-row:last-child {
  border-bottom: none;
}

.sb-key {
  font-size: 0.77rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.sb-val {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.sb-link {
  color: var(--primary);
  text-decoration: none;
}

.sb-link:hover {
  text-decoration: underline;
}

.sb-val-muted {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.sb-val-grow {
  margin-right: auto;
  text-align: left;
}

.sb-val-truncate {
  max-width: 130px;
}

/* Edit rows in admin management card */
.sb-edit-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sb-edit-row:last-child {
  border-bottom: none;
}

.sb-edit-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* Edit pencil button (used both in sidebar and standalone) */
.meta-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  background: none;
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.1s;
  font-family: var(--font);
}

.meta-edit-btn:hover {
  background: var(--primary-dim);
  border-color: var(--primary-mid);
  color: var(--primary);
}

.meta-edit-form {
  display: none;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-edit-form-full {
  width: 100%;
  margin-top: 4px;
}

.edit-input-grow {
  flex: 1;
  width: 100%;
}

/* Action Bar Layout */
.action-bar-layout {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-edit-form.visible {
  display: flex;
}

.meta-edit-form input,
.meta-edit-form select {
  padding: 4px 8px;
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg2);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  max-width: 180px;
}

.meta-edit-form input:focus,
.meta-edit-form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* Status badge inside sidebar */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-badge.completed {
  color: #0284c7;
}

.status-badge.failed {
  color: #dc2626;
}

.status-badge.generating {
  color: #b45309;
}

.status-badge.pending {
  color: var(--text-muted);
}

.status-badge.duplicate {
  color: var(--text-muted);
}

.status-badge.publishing {
  color: var(--primary);
}

.status-badge.published {
  color: #15803d;
}

/* Category badge */
.category-badge {
  display: inline-flex;
  align-items: center;
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border-med);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

.category-badge.dream_book {
  background: rgba(139, 92, 246, 0.06);
  color: #7c3aed;
  border-color: rgba(139, 92, 246, 0.18);
}

.category-badge.bio {
  background: rgba(16, 185, 129, 0.06);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.18);
}

/* Legacy — hidden but keep for JS compatibility */
.detail-header {
  display: none;
}

.detail-meta-row {
  display: none;
}

.detail-body {
  display: none;
}

.detail-columns {
  display: none;
}

.detail-main-col {
  display: none;
}

.detail-side-col {
  display: none;
}

.meta-item {
  display: none;
}

.meta-label {
  display: none;
}

.meta-value {
  display: none;
}

/* ═══════════════════════════════════════════════════════════
   ACCORDION SECTIONS
   ═══════════════════════════════════════════════════════════ */
.section-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.section-block.open {
  box-shadow: var(--shadow-md);
}

.section-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-2);
  user-select: none;
  transition: background 0.1s;
  letter-spacing: -0.01em;
}

.section-block-header:hover {
  background: var(--bg3);
}

.chevron {
  transition: transform 0.2s;
  flex-shrink: 0;
  color: var(--text-light);
}

.section-block.open .chevron {
  transform: rotate(180deg);
}

.section-block-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.section-block-body.hidden {
  display: none;
}

/* ═══════════════════════════════════════════════════════════
   SERP CARDS
   ═══════════════════════════════════════════════════════════ */
.serp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 14px;
}

.serp-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.serp-card-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  margin-bottom: 10px;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════
   CLUSTERS
   ═══════════════════════════════════════════════════════════ */
.clusters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding-top: 14px;
}

.cluster-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.12s;
}

.cluster-card:hover {
  border-color: var(--border-str);
}

.cluster-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.cluster-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 9px;
  line-height: 1.5;
}

/* Keyword chips */
.kw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.kw-chip {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ═══════════════════════════════════════════════════════════
   OUTLINE
   ═══════════════════════════════════════════════════════════ */
#detail-outline-content {
  padding-top: 14px;
}

.outline-section-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  margin-bottom: 4px;
  transition: background 0.1s;
}

.outline-section-item:hover {
  background: var(--bg3);
}

.outline-heading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.heading-tag {
  background: var(--primary-dim);
  color: var(--primary);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.heading-tag-h2 {
  background: var(--primary-dim);
  color: var(--primary-hover);
  border: 1px solid var(--primary-ring);
}

.heading-tag-h3 {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border-med);
}

.outline-heading-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.format-tag {
  background: rgba(22, 163, 74, 0.06);
  color: var(--success);
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  border: 1px solid rgba(22, 163, 74, 0.18);
  flex-shrink: 0;
}

.outline-tz {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
  padding-left: 2px;
}

.outline-indented {
  padding-left: 28px;
  position: relative;
}

.outline-indented::before {
  content: '';
  position: absolute;
  left: 12px;
  top: -4px;
  bottom: 10px;
  width: 1px;
  background: var(--border-med);
}

/* ═══════════════════════════════════════════════════════════
   ARTICLE PREVIEW
   ═══════════════════════════════════════════════════════════ */
.article-action-row {
  display: flex;
  justify-content: flex-end;
  padding: 10px 0;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.article-preview {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text-2);
}

.article-preview h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
}

.article-preview h2 {
  font-size: 1.15rem;
  margin: 24px 0 8px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.article-preview h3 {
  font-size: 0.975rem;
  margin: 18px 0 6px;
  font-weight: 600;
  color: var(--text);
}

.article-preview p {
  margin-bottom: 12px;
}

.article-preview ul,
.article-preview ol {
  margin: 8px 0 12px 20px;
}

.article-preview li {
  margin-bottom: 5px;
}

.article-preview img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 10px 0;
  border: 1px solid var(--border);
}

.article-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.article-preview th,
.article-preview td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 0.85rem;
  text-align: left;
}

.article-preview th {
  background: var(--bg3);
  font-weight: 600;
  color: var(--text);
}

.article-preview a {
  color: var(--primary);
  text-decoration: underline;
}

/* Meta fields (Title / Description copyable blocks) */
.article-meta-blocks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.meta-field-block {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.meta-field-block:hover {
  border-color: var(--primary);
}

.meta-field-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
}

.meta-field-label span {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--primary);
  text-transform: none;
  letter-spacing: 0;
}

.meta-text {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════
   LOGS
   ═══════════════════════════════════════════════════════════ */
#detail-logs-content {
  padding-top: 12px;
}

.log-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 5px;
  font-feature-settings: 'tnum';
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.log-title {
  font-weight: 500;
  font-size: 0.825rem;
  color: var(--text);
}

.log-time {
  font-size: 0.75rem;
  color: var(--text-light);
}

.log-stats {
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.token-total {
  font-weight: 600;
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   FORM ELEMENTS
   ═══════════════════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label,
.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  margin-top: 4px;
}

.checkbox-group input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Stats update modal checkbox grid */
.stats-checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.84rem;
  transition: background 0.12s, border-color 0.12s;
}

.stats-checkbox-item:hover {
  background: var(--bg);
  border-color: var(--primary-light);
}

.stats-checkbox-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}

.kw-input {
  background: var(--bg2);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
  letter-spacing: -0.01em;
}

.kw-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.category-select,
.form-input {
  background: var(--bg2);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
  letter-spacing: -0.01em;
}

.category-select:focus,
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

textarea.kw-input {
  resize: vertical;
  min-height: 70px;
  padding: 8px 10px;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.18s;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--bg2);
  width: 92%;
  max-width: 560px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateY(0) scale(1);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.hidden .modal-content {
  transform: translateY(12px) scale(0.98);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
  background: var(--bg3);
}

/* ═══════════════════════════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════════════════════════ */
.login-container {
  max-width: 360px;
  margin: 80px auto 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-container .brand {
  justify-content: center;
  margin-bottom: 18px;
  margin-right: 0;
}

.login-container .brand::after {
  display: none;
}

.login-container .btn-primary {
  margin-top: 10px;
  padding: 9px;
  font-size: 0.875rem;
  border-radius: var(--radius);
  justify-content: center;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.825rem;
  font-weight: 500;
  max-width: 320px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  letter-spacing: -0.01em;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.toast.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.toast.info {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   PUBLISHED TABLE
   ═══════════════════════════════════════════════════════════ */
.table-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.85rem;
  color: var(--text-2);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background 0.1s;
}

.data-table tbody tr:hover td {
  background: var(--bg3);
}

.data-table tbody tr:hover .table-actions {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════
   SURFACE / CARD
   ═══════════════════════════════════════════════════════════ */
.surface {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ═══════════════════════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-med);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-str);
}

/* ═══════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════ */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

.btn-ghost.btn-sm {
  font-size: 0.775rem;
  padding: 8px 12px;
}

/* Status Banners & Avatars */
.status-banner {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-banner.status-warning {
  background: var(--warning-dim);
  color: var(--warning);
}

.status-banner.status-success {
  background: rgba(21, 128, 61, 0.08);
  color: #15803d;
  border: 1px solid rgba(21, 128, 61, 0.2);
}

.status-banner.status-error {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.manager-avatar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.manager-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-dim);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.65rem;
}

/* Legacy side elements removed */
.side-edit-wrap,
.side-row,
.side-panel,
.side-panel-label,
.side-panel-body {
  display: none;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .detail-layout {
    grid-template-columns: 1fr 240px;
  }

  .detail-sidebar {
    padding: 10px;
  }
}

@media (max-width: 768px) {
  .detail-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .detail-content {
    min-height: 0;
  }

  .detail-sidebar {
    border-top: 1px solid var(--border);
    max-height: 280px;
    overflow-y: auto;
  }

  .serp-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding: 0 14px;
  }

  .page-container {
    padding: 16px 14px;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .clusters-grid {
    grid-template-columns: 1fr;
  }
}