:root {
  --bg: #f5f7fa;
  --bg-soft: rgba(255, 255, 255, 0.95);
  --ink: #1a202c;
  --muted: #718096;
  --line: rgba(0, 0, 0, 0.06);
  --brand: #667eea;
  --brand-dark: #5a67d8;
  --accent: #764ba2;
  --accent-soft: #9f7aea;
  --success: #48bb78;
  --danger: #f56565;
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  --gradient-danger: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(102, 126, 234, 0.15), transparent 35%),
    radial-gradient(circle at bottom right, rgba(118, 75, 162, 0.12), transparent 40%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; transition: all 0.2s ease; }
img { display: block; width: 100%; }
small { color: var(--muted); }

.console-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.shell-bg {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.sidebar {
  position: relative;
  padding: 32px 24px;
  background: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 32px;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%, rgba(255,255,255,0.05) 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--gradient-primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 26px;
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
  transition: transform 0.3s ease;
}

.brand:hover .brand-mark {
  transform: rotate(-5deg) scale(1.05);
}

.brand h1, .brand p { margin: 0; }
.brand h1 { font-size: 20px; }
.brand p { color: rgba(255,255,255,0.65); font-size: 13px; }

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  padding: 14px 18px;
  border-radius: 12px;
  color: rgba(255,255,255,0.75);
  transition: all 0.2s ease;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.nav a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--gradient-primary);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.nav a.active,
.nav a:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  transform: translateX(4px);
}

.nav a.active::before,
.nav a:hover::before {
  transform: scaleY(1);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.user-chip {
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
}

.main {
  position: relative;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand-dark);
}

.topbar h2 {
  margin: 0;
  font-size: 34px;
}

.panel, .stat-card, .login-card {
  background: var(--bg-soft);
  border: 1px solid rgba(255,255,255,0.9);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.panel {
  border-radius: var(--radius);
  padding: 24px;
}

.panel:hover {
  box-shadow: var(--shadow-hover);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  margin-bottom: 18px;
}

.panel-head h3 {
  margin: 0;
  font-size: 22px;
}

.subtle, .empty, .muted, .panel-head p {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 24px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
  transform: translate(30%, -30%);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 500;
  font-size: 14px;
}

.stat-card strong {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card small {
  color: var(--muted);
  font-size: 13px;
}

.stat-card.accent {
  background: var(--gradient-primary);
  color: #fff;
}

.stat-card.accent::before {
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
}

.stat-card.accent span,
.stat-card.accent small {
  color: rgba(255,255,255,0.85);
}

.stat-card.accent strong {
  background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
}

.article-preview-layout {
  align-items: start;
}

.preview-panel {
  position: sticky;
  top: 24px;
}

.article-preview-frame {
  width: 100%;
  min-height: 760px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  background: linear-gradient(180deg, #f7f1e7 0%, #efe8dc 100%);
}

.generator-preview-block {
  margin-top: 18px;
}

.dashboard-grid {
  grid-template-columns: 1.5fr 1fr;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.avatar-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.avatar-card {
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(0,0,0,0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
  border-color: rgba(102, 126, 234, 0.3);
}

.avatar-card.selected {
  border-color: var(--brand);
  box-shadow: 0 16px 40px rgba(102, 126, 234, 0.25);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
}

.avatar-card.dragging {
  opacity: 0.55;
}

.avatar-cover {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.preview-trigger { cursor: pointer; }

.avatar-card img {
  height: 100%;
  object-fit: cover;
}

.avatar-meta {
  padding: 16px;
}

.avatar-meta h3, .avatar-meta h4 {
  margin: 0 0 8px;
  font-size: 18px;
}

.avatar-meta p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 16px;
  align-items: stretch;
}

.card-actions form {
  margin: 0;
  width: 100%;
}

.card-actions a,
.card-actions button {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  text-align: center;
}

.danger-btn {
  background: rgba(192, 57, 43, 0.12) !important;
  color: var(--danger) !important;
}

.primary-btn, .ghost-btn, .card-actions button {
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.primary-btn {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
}

.ghost-btn, .card-actions button {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.ghost-btn:hover, .card-actions button:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.wide { width: 100%; }

.status-chip {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(8px);
}

.status-chip.on { 
  background: var(--gradient-success);
}
.status-chip.off { 
  background: var(--gradient-danger);
}

.preview-pill {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(8px);
}

.drag-handle {
  position: absolute;
  left: 14px;
  top: 12px;
  z-index: 3;
  width: 34px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(31, 41, 55, 0.58);
  color: #fff;
  cursor: grab;
  font-size: 14px;
  letter-spacing: 2px;
}

.tag-stack {
  display: grid;
  gap: 12px;
}

.tag-stack.spaced {
  margin-top: 18px;
}

.tag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
}

.smart-form, .filter-bar {
  display: grid;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.span-2 {
  grid-column: span 2;
}

.inline-field {
  align-content: end;
}

.field label {
  font-size: 14px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,0.95);
  font: inherit;
  transition: all 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: #fff;
}

.field input[type="checkbox"] {
  width: auto;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.module-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.shortcut-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(102, 126, 234, 0.14);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.shortcut-card strong {
  font-size: 16px;
}

.shortcut-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.shortcut-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08);
}

.shortcut-card.accent {
  background: var(--gradient-primary);
  color: #fff;
}

.shortcut-card.accent span {
  color: rgba(255, 255, 255, 0.88);
}

.filter-bar {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
}

.bulk-panel {
  margin-top: 20px;
}

.bulk-form {
  display: grid;
  gap: 20px;
}

.bulk-toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.bulk-hint {
  color: var(--muted);
  font-size: 14px;
}

.select-badge {
  position: absolute;
  z-index: 2;
  top: 48px;
  left: 14px;
}

.select-badge input {
  width: 18px;
  height: 18px;
}

.selection-order {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1f2937, #334155);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.24);
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 24px;
  color: var(--muted);
}

.messages {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.table-card {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

#generated-html {
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.5;
}

.message {
  padding: 14px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(72, 187, 120, 0.15), rgba(56, 161, 105, 0.1));
  color: #276749;
  border-left: 4px solid var(--success);
  font-weight: 500;
}

.message.error {
  background: linear-gradient(135deg, rgba(245, 101, 101, 0.15), rgba(229, 62, 62, 0.1));
  color: #c53030;
  border-left-color: var(--danger);
}

.error-list {
  color: var(--danger);
  font-size: 13px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(1100px, 100%);
  border-radius: 32px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
}

.login-hero {
  padding: 56px;
  background:
    linear-gradient(135deg, rgba(102,126,234,0.95), rgba(118,75,162,0.88)),
    url("https://images.unsplash.com/photo-1517841905240-472988babdf9") center/cover;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.login-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: float 20s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-30px, -30px) rotate(180deg); }
}

.login-hero h1 {
  font-size: 46px;
  line-height: 1.14;
  margin: 0 0 18px;
}

.login-hero p {
  max-width: 430px;
  color: rgba(255,255,255,0.82);
  line-height: 1.7;
}

.login-form {
  padding: 56px 44px;
  background: rgba(255,255,255,0.92);
  display: grid;
  gap: 18px;
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.empty-panel {
  grid-column: 1 / -1;
  text-align: center;
}

.chart-shell {
  min-height: 240px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  padding-top: 10px;
}

.chart-col {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.chart-bar-wrap {
  width: 100%;
  min-height: 200px;
  display: flex;
  align-items: end;
}

.chart-bar {
  width: 100%;
  border-radius: 12px 12px 8px 8px;
  background: var(--gradient-primary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  color: #fff;
  padding-top: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chart-bar:hover {
  transform: scaleY(1.05);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.chart-col label {
  font-size: 13px;
  color: var(--muted);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cloud-tag {
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.08));
  color: var(--brand);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.cloud-tag:hover {
  background: var(--gradient-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.upload-workbench-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 24px;
}

.upload-stage {
  display: grid;
  gap: 16px;
}

.dropzone {
  min-height: 280px;
  border-radius: 20px;
  border: 2px dashed rgba(102, 126, 234, 0.4);
  background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(247, 250, 255, 0.95));
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  transition: all 0.3s ease;
}

.dropzone:hover {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(247, 250, 255, 1), rgba(237, 242, 255, 1));
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
}

.dropzone.dragging {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(237, 242, 255, 1), rgba(224, 231, 255, 1));
  transform: scale(1.02);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.25);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-copy {
  max-width: 340px;
  padding: 20px;
}

.dropzone-copy strong {
  display: block;
  font-size: 22px;
  margin-bottom: 10px;
}

.dropzone-copy span {
  color: var(--muted);
  line-height: 1.6;
}

.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.preview-tile {
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.76);
  border: 1px solid rgba(255,255,255,0.82);
}

.preview-tile img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.preview-tile span {
  display: block;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-fields {
  display: grid;
  gap: 18px;
}

.helper-panel {
  padding: 18px;
  border-radius: 20px;
  background: rgba(38, 70, 83, 0.06);
}

.helper-panel h4 {
  margin: 0 0 10px;
}

.helper-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 30;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: min(980px, 100%);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 24px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
}

.modal-image-wrap {
  min-height: 560px;
  background: #fff4ea;
}

.modal-image-wrap img {
  height: 100%;
  object-fit: cover;
}

.modal-meta {
  padding: 28px;
  display: grid;
  align-content: center;
  gap: 14px;
}

.preview-info {
  display: grid;
  gap: 10px;
}

.preview-info span {
  padding: 12px 14px;
  background: rgba(31, 41, 55, 0.05);
  border-radius: 14px;
}

@media (max-width: 960px) {
  .content-grid,
  .upload-workbench-grid,
  .modal-layout,
  .bulk-toolbar,
  .filter-bar,
  .form-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }

  .article-preview-frame {
    min-height: 560px;
  }
}

.modal-close {
  position: absolute;
  right: 20px;
  top: 20px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  cursor: pointer;
  font-size: 24px;
  color: var(--ink);
  transition: all 0.2s ease;
  display: grid;
  place-items: center;
  z-index: 10;
}

.modal-close:hover {
  background: var(--danger);
  color: #fff;
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 4px 12px rgba(245, 101, 101, 0.4);
}

@media (max-width: 1200px) {
  .stats-grid,
  .content-grid,
  .dashboard-grid,
  .avatar-grid,
  .form-grid,
  .filter-bar,
  .login-card,
  .upload-workbench-grid,
  .bulk-toolbar,
  .modal-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .console-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
}
