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

:root {
  --brand-purple: #6B31EB;
  --brand-indigo: #3730A3;
  --brand-navy:   #04112A;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--brand-navy);
  background: #f5f5f5;
  height: 100vh;
  overflow: hidden;
}

/* LAYOUT */
.shell { display: flex; height: 100vh; }

.sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.logo {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e5e5e5;
}

.logo-img { height: 30px; width: auto; display: block; }

nav { padding: 8px; }

.nav-item {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #666;
  text-decoration: none;
  margin-bottom: 2px;
  transition: background .1s;
}

.nav-item:hover { background: rgba(107,49,235,.05); color: var(--brand-navy); }
.nav-item.active { background: rgba(107,49,235,.08); color: var(--brand-navy); font-weight: 700; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.current-user { font-size: 12px; color: #999; margin-right: 4px; }

.content { flex: 1; overflow-y: auto; padding: 20px; }

/* VIEWS */
.view { display: none; }
.view.active { display: block; }

/* METRICS */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 14px;
}

.metric-label { font-size: 11px; color: #999; margin-bottom: 6px; }
.metric-value { font-size: 26px; font-weight: 700; color: var(--brand-navy); }
.metric-sub { font-size: 11px; color: #bbb; margin-top: 4px; }

/* SECTION HEADER */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title { font-size: 13px; font-weight: 700; color: var(--brand-navy); }

/* SEARCH */
.search-input {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 6px;
  border: 1px solid #e5e5e5;
  font-size: 13px;
  color: var(--brand-navy);
  font-family: inherit;
}

.search-input:focus { outline: none; border-color: var(--brand-purple); box-shadow: 0 0 0 3px rgba(107,49,235,.15); }

/* FILTERS */
.filters { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }

.filter-pill {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid #e5e5e5;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: #666;
  transition: all .1s;
}

.filter-pill:hover { border-color: #ccc; color: var(--brand-navy); }
.filter-pill.active { background: var(--brand-purple); border-color: var(--brand-purple); color: #fff; }

/* TABLE */
.table {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
}

.table-header {
  display: grid;
  grid-template-columns: 1fr 100px 110px 80px;
  padding: 0 12px;
  background: #fafafa;
  border-bottom: 1px solid #e5e5e5;
}

.th {
  padding: 9px 8px;
  font-size: 11px;
  color: #999;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 100px 110px 80px;
  padding: 0 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background .1s;
}

.table-row:last-child { border-bottom: none; }
.table-row:hover { background: #fafafa; }

.td {
  padding: 10px 8px;
  font-size: 13px;
  color: var(--brand-navy);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.td-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 1.4;
  padding-top: 11px;
}

/* BADGES */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-PENDING    { background: #f0f0f0; color: #666; }
.badge-GENERATED  { background: #dbeafe; color: #1d4ed8; }
.badge-APPROVED   { background: #dcfce7; color: #15803d; }
.badge-PUBLISHED  { background: rgba(55,48,163,.1); color: var(--brand-indigo); }
.badge-REJECTED   { background: #fee2e2; color: #b91c1c; }

/* BUTTONS */
.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: var(--brand-navy);
  transition: background .1s;
  white-space: nowrap;
}

.btn:hover { background: #f5f5f5; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand-purple); border-color: var(--brand-purple); color: #fff; }
.btn-primary:hover { background: var(--brand-indigo); border-color: var(--brand-indigo); }
.btn-danger { border-color: #fca5a5; color: #b91c1c; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* PANEL */
.panel {
  width: 0;
  overflow: hidden;
  background: #fff;
  border-left: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  transition: width .2s ease;
  flex-shrink: 0;
}

.panel.open { width: 400px; }

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-title { font-size: 13px; font-weight: 700; }

.close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0 4px;
}

.close-btn:hover { color: var(--brand-navy); }

.panel-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.panel-footer {
  padding: 12px 16px;
  border-top: 1px solid #e5e5e5;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* DESCRIPTION BLOCKS */
.desc-block { display: flex; flex-direction: column; gap: 6px; }

.desc-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #999;
}

.desc-text {
  font-size: 12px;
  color: #555;
  line-height: 1.7;
  background: #fafafa;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 10px 12px;
}

.desc-text.generated {
  background: rgba(107,49,235,.05);
  border-color: rgba(107,49,235,.25);
  color: var(--brand-indigo);
}

.desc-text h2 {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--brand-indigo);
}

.desc-text p { margin-bottom: 6px; }
.desc-text p:last-child { margin-bottom: 0; }
.desc-text a { color: var(--brand-purple); }

/* SETTINGS */
.settings-form {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-navy);
}

.settings-form textarea,
.settings-form select {
  padding: 8px 10px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--brand-navy);
  resize: vertical;
}

.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.saved-msg { font-size: 12px; color: #15803d; }

.file-upload-row { display: flex; align-items: center; gap: 10px; }
.file-upload-btn { cursor: pointer; }
.file-upload-btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.file-upload-name { font-size: 12px; color: #6b7280; font-weight: 400; }
.char-count { font-size: 11px; color: #9ca3af; font-weight: 400; }

/* KEYWORD CHIPS */
.keyword-tags { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.keyword-chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(107,49,235,.08); border: 1px solid rgba(107,49,235,.3); border-radius: 20px; padding: 2px 8px 2px 12px; font-size: 12px; color: var(--brand-indigo); }
.keyword-chip-remove { background: none; border: none; cursor: pointer; color: var(--brand-purple); font-size: 16px; line-height: 1; padding: 0 2px; opacity: .6; }
.keyword-chip-remove:hover { opacity: 1; }
.keyword-add-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.keyword-input { flex: 1; padding: 5px 10px; font-size: 12px; border: 1px solid #e5e5e5; border-radius: 6px; font-family: inherit; }
.keyword-input:focus { outline: none; border-color: var(--brand-purple); box-shadow: 0 0 0 3px rgba(107,49,235,.15); }

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brand-navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 100;
}

.toast.show { opacity: 1; }

/* INLINE EDIT TEXTAREAS */
.desc-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.7;
  color: var(--brand-indigo);
  background: rgba(107,49,235,.05);
  border: 1px solid rgba(107,49,235,.25);
  border-radius: 6px;
  padding: 10px 12px;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.desc-textarea:focus {
  outline: none;
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 3px rgba(107,49,235,.15);
}
.desc-textarea--html {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  color: #374151;
  background: #f8fafc;
  border-color: #e2e8f0;
}
.desc-textarea--html:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148,163,184,.15);
}
.desc-meta-counter { font-size: 11px; color: #999; text-align: right; margin-top: 2px; }
.desc-block--save  { flex-direction: row; align-items: center; gap: 10px; }
.desc-save-status  { font-size: 12px; color: #999; }
.desc-save-status--ok  { color: #15803d; }
.desc-save-status--err { color: #b91c1c; }