* {
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --bg-soft: #f5f5f5;
  --surface: #ffffff;
  --text: #242424;
  --text-strong: #111111;
  --muted: #898989;
  --line: rgba(34, 42, 53, 0.1);
  --ring: rgba(34, 42, 53, 0.08);
  --danger: #242424;
  --shadow-card:
    rgba(19, 19, 22, 0.7) 0 1px 5px -4px,
    rgba(34, 42, 53, 0.08) 0 0 0 1px,
    rgba(34, 42, 53, 0.05) 0 4px 8px 0;
  --shadow-soft:
    rgba(36, 36, 36, 0.7) 0 1px 5px -4px,
    rgba(36, 36, 36, 0.05) 0 4px 8px;
  --radius: 8px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  background: #ffffff;
  color: var(--text);
  display: flex;
  flex-direction: column;
  box-shadow: rgba(34, 42, 53, 0.08) 1px 0 0 0;
}

.sidebar-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 18px;
  box-shadow: rgba(34, 42, 53, 0.08) 0 1px 0 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #242424;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
}

.brand-subtitle,
.operator-role {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
  background: #f5f5f5;
}

.nav-code {
  width: 24px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  padding: 14px;
}

.operator-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

.operator-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: #242424;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.operator-name {
  font-size: 14px;
  font-weight: 600;
}

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: 244px;
  background: #fafafa;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: rgba(34, 42, 53, 0.08) 0 1px 0 0;
  backdrop-filter: blur(12px);
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.content-area {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.page-content {
  display: none;
}

.page-content.active {
  display: block;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card,
.panel,
.asset-box,
.setting-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.metric-card {
  padding: 18px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-label,
.metric-note,
.form-hint,
.panel-header p,
.record-meta,
.record-link {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  display: block;
  margin-top: 10px;
  color: var(--text-strong);
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dashboard-layout,
.editor-layout,
.workspace-rail {
  display: grid;
  gap: 16px;
}

.dashboard-layout {
  grid-template-columns: 1fr;
}

.editor-layout {
  grid-template-columns: minmax(520px, 1.05fr) minmax(360px, 0.75fr);
  align-items: start;
}

.workspace-rail {
  grid-template-columns: 1fr;
}

.workspace-rail .panel {
  min-width: 0;
}

.panel {
  overflow: hidden;
}

.panel-header {
  min-height: 68px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: rgba(34, 42, 53, 0.08) 0 1px 0 0;
}

.panel-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

.panel-header p {
  margin: 4px 0 0;
}

.panel-body {
  padding: 18px 20px 20px;
}

.quality-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.quality-item,
.filter-chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9999px;
  background: #f5f5f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: rgba(34, 42, 53, 0.08) 0 0 0 1px;
}

.quality-item.done {
  background: #242424;
  color: #ffffff;
}

.panel-footer {
  padding: 0 20px 20px;
}

.field-row,
.asset-grid,
.settings-grid,
.security-grid,
.batch-grid {
  display: grid;
  gap: 12px;
}

.field-row {
  grid-template-columns: 0.45fr 1fr;
}

.asset-grid,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.security-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented-control {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented-control label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 9999px;
  background: #ffffff;
  box-shadow: var(--shadow-card);
  cursor: pointer;
}

.segmented-control input {
  margin: 0;
}

.batch-panel {
  margin-bottom: 16px;
}

.security-panel {
  margin-top: 16px;
}

.batch-grid {
  grid-template-columns: 150px 150px minmax(180px, 1fr) auto;
  align-items: end;
}

.batch-grid .form-group {
  margin-bottom: 0;
}

.batch-description {
  grid-column: 1 / -1;
}

.batch-description .form-textarea {
  min-height: 74px;
}

.setting-card,
.asset-box {
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.settings-grid .setting-card:first-child {
  grid-row: span 2;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.form-input,
.form-textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  box-shadow:
    rgba(34, 42, 53, 0.1) 0 0 0 1px,
    rgba(34, 42, 53, 0.05) 0 1px 2px;
  transition: box-shadow 0.18s ease;
}

.form-textarea {
  min-height: 176px;
  resize: vertical;
}

.rich-editor {
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  box-shadow:
    rgba(34, 42, 53, 0.1) 0 0 0 1px,
    rgba(34, 42, 53, 0.05) 0 1px 2px;
}

.rich-editor .ql-toolbar.ql-snow {
  border: 0;
  box-shadow: rgba(34, 42, 53, 0.08) 0 1px 0 0;
  background: #ffffff;
}

.rich-editor .ql-container.ql-snow {
  border: 0;
  min-height: 260px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
}

.rich-editor .ql-editor {
  min-height: 260px;
  line-height: 1.9;
}

.rich-editor .ql-editor img,
.preview-description img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

.rich-editor .ql-editor *,
.preview-description * {
  max-width: 100%;
  box-sizing: border-box;
}

.rich-editor .ql-editor audio,
.preview-description audio {
  display: block;
  width: 100%;
  max-width: 100%;
}

.settings-editor .ql-container.ql-snow,
.settings-editor .ql-editor {
  min-height: 188px;
}

.ql-toolbar .ql-source {
  width: auto;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: #242424;
  font: inherit;
  cursor: pointer;
}

.rich-editor .ql-editor.ql-blank::before {
  color: var(--muted);
  font-style: normal;
}

.form-input:focus,
.form-textarea:focus,
.rich-editor:focus-within {
  box-shadow:
    rgba(59, 130, 246, 0.5) 0 0 0 2px,
    rgba(34, 42, 53, 0.05) 0 4px 8px;
}

.compact-search {
  width: min(280px, 100%);
}

.list-header {
  align-items: center;
}

.filter-bar {
  display: flex;
  gap: 8px;
  padding: 14px 20px 0;
  flex-wrap: wrap;
}

.filter-chip {
  cursor: pointer;
  padding: 7px 11px;
  background: #ffffff;
}

.filter-chip.active {
  background: #242424;
  color: #ffffff;
  box-shadow:
    rgba(255, 255, 255, 0.15) 0 2px 0 inset,
    rgba(0, 0, 0, 0.16) 0 1px 1.9px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 0;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.btn:hover {
  opacity: 0.72;
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.btn-primary {
  background: #242424;
  color: #fff;
  box-shadow:
    rgba(255, 255, 255, 0.15) 0 2px 0 inset,
    rgba(0, 0, 0, 0.16) 0 1px 1.9px;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.btn-danger {
  background: #ffffff;
  color: #242424;
  box-shadow: var(--shadow-card);
}

.btn-sm {
  min-height: 32px;
  padding: 7px 10px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow:
    rgba(34, 42, 53, 0.08) 0 0 0 1px,
    rgba(34, 42, 53, 0.05) 0 4px 8px 0;
}

.record-item > div:first-child {
  min-width: 0;
}

.record-item.is-incomplete {
  background: #ffffff;
}

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

.record-title {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-description {
  margin: 8px 0;
  color: #666666;
  font-size: 13px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.record-meta,
.record-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 9999px;
  background: #242424;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.muted {
  background: #f5f5f5;
  color: var(--muted);
}

.phone-preview {
  overflow: hidden;
  border-radius: 18px;
  background: #ffffff;
  box-shadow:
    rgba(34, 42, 53, 0.12) 0 0 0 1px,
    rgba(34, 42, 53, 0.08) 0 14px 32px -18px;
}

.preview-cover {
  min-height: 188px;
  background: #f5f5f5;
  background-size: cover;
  background-position: center;
  box-shadow: rgba(34, 42, 53, 0.08) 0 -1px 0 0 inset;
}

.preview-cover.has-image {
  min-height: 220px;
}

.preview-content {
  padding: 20px;
}

.preview-content h3 {
  margin: 0 0 12px;
  color: var(--text-strong);
  font-size: 26px;
  line-height: 1.18;
}

.preview-states {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.preview-states span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 9999px;
  background: #f5f5f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  box-shadow: rgba(34, 42, 53, 0.08) 0 0 0 1px;
}

.preview-description {
  color: #555555;
  font-size: 14px;
  line-height: 1.8;
  max-height: 210px;
  overflow: hidden;
}

.preview-description p,
.preview-description ul,
.preview-description ol,
.preview-description blockquote,
.preview-description h2,
.preview-description h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.image-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.image-preview-item {
  position: relative;
  width: 116px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: #f5f5f5;
  box-shadow: rgba(34, 42, 53, 0.08) 0 0 0 1px;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-preview-item button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 9999px;
  background: rgba(36, 36, 36, 0.88);
  color: #fff;
  cursor: pointer;
}

.current-audio audio {
  width: 100%;
  margin-top: 12px;
}

.setting-preview {
  margin-top: 14px;
  color: var(--muted);
}

.setting-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  padding: 16px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-card);
}

.summary-card strong {
  display: block;
  color: var(--text);
  font-size: 24px;
  margin-bottom: 4px;
}

.asset-list,
.analytics-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.asset-row,
.analytics-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-card);
}

.asset-thumb {
  width: 76px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #f5f5f5;
  box-shadow: rgba(34, 42, 53, 0.08) 0 0 0 1px;
}

.asset-info strong,
.analytics-info strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.asset-info span,
.analytics-info span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.loading-text,
.empty-state {
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
}

.message {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #242424;
  color: #fff;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.message.show {
  opacity: 1;
  transform: translateY(0);
}

.message.error {
  background: #242424;
}

@media (max-width: 1180px) {
  .overview-grid,
  .dashboard-layout,
  .editor-layout,
  .workspace-rail,
  .settings-grid,
  .security-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .sidebar-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .app-container {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .content-area {
    padding: 18px;
  }

  .overview-grid,
  .field-row,
  .summary-grid,
  .batch-grid {
    grid-template-columns: 1fr;
  }

  .record-item {
    grid-template-columns: 1fr;
  }

  .record-actions {
    justify-content: flex-start;
  }
}
