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

:root {
  --bg:           #F4F1EC;
  --surface:      #FFFFFF;
  --surface2:     #F9F7F4;
  --surface3:     #F0EDE8;
  --navy:         #1A1E2E;
  --navy2:        #2C3150;
  --border:       #E0DAD2;
  --border-dark:  #C8C0B4;
  --gold:         #B8943A;
  --gold-light:   #D4AF6A;
  --gold-dim:     #8A6E2C;
  --text:         #1A1E2E;
  --text2:        #5A5850;
  --text3:        #9A9590;
  --danger:       #B04840;
  --success:      #3A7A52;
  --warn:         #A07030;
  --radius:       2px;
  --font-head:    'Cormorant Garamond', Georgia, serif;
  --font-body:    'Open Sans', system-ui, sans-serif;
  --shadow:       0 1px 4px rgba(26,30,46,0.08), 0 4px 16px rgba(26,30,46,0.04);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  height: 64px;
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-prmc {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.22em;
}
.logo-divider {
  color: rgba(255,255,255,0.2);
  font-weight: 300;
}
.logo-sub {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 400;
  font-style: italic;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.03em;
}

nav { display: flex; gap: 0; }
.tab-btn {
  padding: 8px 24px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.45);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: rgba(255,255,255,0.75); }
.tab-btn.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold-light);
}

/* ── Tabs ────────────────────────────────────────────────────────── */
.tab { display: none; padding: 48px; }
.tab.active { display: block; }
.panel { max-width: 1080px; margin: 0 auto; }
#tab-database .panel { max-width: 1600px; }

/* ── Page header ─────────────────────────────────────────────────── */
.page-header { margin-bottom: 36px; }
.page-header h1 {
  font-family: var(--font-head);
  font-size: 40px;
  font-weight: 400;
  font-style: italic;
  color: var(--navy);
  letter-spacing: 0.01em;
  line-height: 1.1;
  margin-bottom: 8px;
}
.page-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* ── Forms ───────────────────────────────────────────────────────── */
.form-row.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.field:last-child { margin-bottom: 0; }

label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
}
.label-note {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text3);
}

input[type="text"],
input[type="date"],
select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  border-radius: var(--radius);
  appearance: none;
  -webkit-appearance: none;
}
input[type="text"]::placeholder { color: var(--text3); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: opacity(0.4); }
input[type="text"]:focus,
input[type="date"]:focus,
select:focus { border-color: var(--gold); outline: none; }

/* File drop zone */
.file-drop {
  position: relative;
  border: 1px dashed var(--border-dark);
  padding: 20px 24px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface2);
}
.file-drop:hover { border-color: var(--gold); background: #FBF8F3; }
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-label {
  color: var(--text3);
  font-size: 12px;
  letter-spacing: 0.03em;
  pointer-events: none;
}
.file-label.has-file { color: var(--gold-dim); font-weight: 500; }

/* Toggle */
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-track {
  width: 36px;
  height: 20px;
  background: var(--surface3);
  border: 1px solid var(--border-dark);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--border-dark);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-label input:checked + .toggle-track { background: var(--gold-dim); border-color: var(--gold-dim); }
.toggle-label input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); background: #fff; }

/* ── Icons ───────────────────────────────────────────────────────── */
/* Shared visual language for every icon in the app (buttons, status
   markers, table cells) — thin-stroke outline SVGs instead of emoji, sized
   and aligned consistently wherever they appear. */
.icon-svg, .btn-icon svg, .td-url svg { flex-shrink: 0; vertical-align: -0.15em; }
.btn-icon { display: inline-flex; align-items: center; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--navy);
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: var(--radius);
}
.btn-primary:hover { background: var(--navy2); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--navy);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: var(--radius);
}
.btn-outline:hover { background: var(--navy); color: #fff; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border-dark);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: var(--radius);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text2); }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--danger);
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: var(--radius);
}
.btn-danger:hover { background: #8A3030; }

/* Gold accent CTA variant */
.btn-gold {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--gold);
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: var(--radius);
}
.btn-gold:hover { background: var(--gold-dim); }

/* ── Progress ────────────────────────────────────────────────────── */
.progress-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
#progress-title {
  font-family: var(--font-head);
  font-size: 20px;
  font-style: italic;
  color: var(--navy);
}
#progress-log {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.log-line {
  font-size: 12px;
  color: var(--text2);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
  font-family: 'Courier New', monospace;
}
.log-line.done { color: var(--success); font-weight: 500; }
.log-line.error { color: var(--danger); }

/* Spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result card ─────────────────────────────────────────────────── */
.result-card {
  text-align: center;
  padding: 48px 32px;
  border-top: 3px solid var(--gold);
  background: #FDFBF8;
}
.result-icon {
  color: var(--gold);
  margin-bottom: 16px;
  display: block;
}
.result-card h2 {
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 400;
  font-style: italic;
  color: var(--navy);
  margin-bottom: 10px;
}
.result-summary {
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 28px;
}
.result-actions { display: flex; gap: 12px; justify-content: center; }

/* ── Database / Archive tab ──────────────────────────────────────── */
.filters-card { padding: 24px 32px; }
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.field-inline { display: flex; flex-direction: column; gap: 7px; }
.field-inline label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
}
.field-inline input,
.field-inline select {
  min-width: 115px;
  padding: 9px 10px;
  font-size: 12px;
}
/* Every filter field grows to fill the row instead of leaving space on the
   right (flex-basis below is a starting proportion, not a hard width) — Week
   gets a larger share since its option labels ("JunW4 (2026-06-22 →
   2026-06-29)") need the most room, per direct request that it read wider. */
.fi-brand, .fi-group    { flex: 1.1 1 110px; }
.fi-tag, .fi-class      { flex: 0.9 1 100px; }
.fi-location            { flex: 1.1 1 120px; }
.fi-week                { flex: 1.7 1 160px; }
.fi-date                { flex: 0.9 1 110px; }
.filter-actions { flex: 0 0 auto; display: flex; gap: 6px; align-items: flex-end; }
/* Compact variant scoped to the Archive filter row only — the shared
   .btn-outline/.btn-ghost padding elsewhere (Generate, Send, Import) stays
   as-is; this just keeps Search/Export the same 36px height as every other
   filter control (see .filter-dd-trigger below). */
.filter-actions .btn-outline,
.filter-actions .btn-ghost {
  padding: 0 14px;
  height: 36px;
}

/* One shared trigger + popover pattern for every dropdown-style filter
   (Brand/Group/Tag multi-select, Class/Week single-select, Location's
   cascading flyout, From/To's calendar) — a single height/border/font here
   is what makes every filter box in the row line up consistently. */
.filter-dd { position: relative; width: 100%; }
.filter-dd-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  height: 36px;
  padding: 0 10px 0 12px;
  font-family: var(--font-body);
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.filter-dd-trigger:hover { border-color: var(--gold-dim); }
.filter-dd-trigger.open { border-color: var(--gold); }
.filter-dd-trigger > span:first-child {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-dd-trigger .caret { color: var(--text3); font-size: 10px; flex-shrink: 0; }
.loc-trigger-clear {
  color: var(--text3);
  font-size: 11px;
  padding: 2px;
  border-radius: 50%;
  flex-shrink: 0;
}
.loc-trigger-clear:hover { color: var(--danger); background: var(--surface3); }
.loc-trigger-clear.hidden { display: none; }

.filter-dd-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-dd-panel.hidden { display: none; }

/* Multi-select (Brand / Group / Tag): a search box filters a click-to-toggle
   list; picks are tracked as a set and shown in the Active Filters bar below
   the whole card, not inline here — that's what keeps this trigger's height
   fixed no matter how many values are selected. */
.ms-panel { min-width: 230px; }
.ms-search {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 12px;
  font-family: var(--font-body);
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  background: transparent;
}
.ms-list { max-height: 240px; overflow-y: auto; }
.ms-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
}
.ms-item:hover { background: var(--surface3); }
.ms-item.selected { color: var(--gold-dim); font-weight: 600; }
.ms-check { width: 14px; flex-shrink: 0; color: var(--gold); font-weight: 700; }
.ms-label small { display: block; color: var(--text3); font-size: 10px; margin-top: 1px; font-weight: 400; }
.ms-empty { padding: 10px 12px; font-size: 12px; color: var(--text3); font-style: italic; }

/* Single-select (Class / Week) */
.ss-list { min-width: 190px; max-height: 260px; overflow-y: auto; }
.ss-item { padding: 8px 14px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.ss-item:hover { background: var(--surface3); }
.ss-item.selected { background: var(--surface3); color: var(--gold-dim); font-weight: 600; }

/* Location filter: cascading Continent → Country → City → Venue flyout —
   columns reveal left-to-right as each tier is picked. Shares .filter-dd /
   .filter-dd-trigger / .filter-dd-panel for the trigger + popover chrome. */
.loc-panel { display: flex; }
.loc-col {
  min-width: 150px;
  max-height: 280px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.loc-col:last-child { border-right: none; }
.loc-col.hidden { display: none; }
.loc-item {
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}
.loc-item:hover { background: var(--surface3); }
.loc-item.selected { background: var(--surface3); color: var(--gold-dim); font-weight: 600; }
.loc-item-arrow { color: var(--text3); font-size: 10px; }

/* Calendar (From / To) — a themed month grid replacing the native
   <input type=date> popup, which no browser lets you restyle with CSS. */
.cal-panel { padding: 12px; width: 232px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text2);
  padding: 2px 10px;
  border-radius: var(--radius);
}
.cal-nav:hover { color: var(--gold-dim); background: var(--surface3); }
.cal-month-label { font-size: 12px; font-weight: 700; letter-spacing: 0.03em; color: var(--text); }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-align: center;
  margin-bottom: 4px;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  text-align: center;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
}
.cal-day:hover { background: var(--surface3); }
.cal-day.other-month { visibility: hidden; }
.cal-day.today { border: 1px solid var(--gold-dim); }
.cal-day.selected { background: var(--gold); color: #fff; font-weight: 700; }
.cal-footer { margin-top: 8px; text-align: right; }
.cal-clear {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
}
.cal-clear:hover { color: var(--danger); }

/* Active Filters — one removable chip per selected value across every
   field, so what's currently applied is visible at a glance in one place
   rather than only inside each dropdown. */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.active-filters.hidden { display: none; }
.af-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border-dark);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text2);
}
.af-chip-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text3);
  font-size: 11px;
  cursor: pointer;
}
.af-chip-remove:hover { background: var(--danger); color: #fff; }
.af-clear-all {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}
.af-clear-all:hover { color: var(--text); }

.db-stats {
  font-size: 12px;
  color: var(--text3);
  letter-spacing: 0.03em;
  margin-bottom: 10px;
  padding-left: 2px;
}

.table-card { padding: 0; overflow: hidden; }
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead tr { background: var(--surface3); }
th {
  padding: 11px 16px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
  color: var(--text2);
  text-align: center;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAF7F2; color: var(--text); }
.td-brief { min-width: 200px; max-width: 340px; color: var(--text); font-weight: 500; }
/* Body / Details EN / Wecom Message carry full paragraphs — centering those
   makes every line a different length and hurts readability, so they stay
   left-aligned while every other data cell is centered. */
.td-body { min-width: 320px; max-width: 560px; color: var(--text2); font-size: 12px; line-height: 1.7; text-align: left; }
.td-brand strong { color: var(--navy); font-weight: 600; }
.td-brand small { color: var(--text3); font-size: 11px; display: block; margin-top: 2px; }
.td-url a {
  color: var(--gold-dim);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.td-url a:hover { color: var(--gold); text-decoration: underline; }

/* Date/Tag columns: sized so a single date ("6月23日", ≤84px measured) or a
   single-phrase tag ("全球市场动态", ≤82px measured) stays on one line, but a
   date period ("6月29日-7月19日", ≥118px measured) or the combined tag
   ("本土市场动态 Premier独家", 152px measured) wraps at its natural word/dash
   break instead of forcing the whole column wide enough for the rare long
   case. `max-width` alone doesn't hold a column open — the table's automatic
   layout will still squeeze it thinner if other columns want the room — so
   `min-width` is set to the same value to actually reserve the space. */
.td-date { min-width: 95px; max-width: 95px; white-space: normal; word-break: break-word; }

/* The <td> wrapping the pill needs its own reserved width too (pill max-width
   92px + the cell's 16px×2 padding), otherwise the same auto-layout squeeze
   hits the cell before the pill's own max-width ever comes into play. */
.td-tag { min-width: 124px; max-width: 124px; }

.tag-pill {
  display: inline-block;
  max-width: 92px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: normal;
  line-height: 1.4;
  border: 1px solid;
}
.tag-domestic { border-color: #A8D4B8; color: #2A6A42; background: #EEF8F2; }
.tag-global   { border-color: #A8B8D8; color: #1A3A6A; background: #EEF2F8; }
.tag-capital  { border-color: #D4B870; color: #7A5A1A; background: #FAF4E4; }
.tag-premier  { border-color: #C4A8D4; color: #5A2A7A; background: #F4EEF8; }

.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 24px;
}
.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-dark);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-body);
  transition: all 0.15s;
}
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.page-btn:hover:not(.active) { border-color: var(--navy); color: var(--navy); }

/* ── Row Editor: two-region shell ───────────────────────────────── */
#tab-editor.tab { padding: 0; }
.editor-shell { display: flex; align-items: flex-start; min-height: calc(100vh - 64px); }

.editor-sidebar {
  width: 324px;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.editor-sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#editor-sidebar-title {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
}
.editor-sidebar-sub { display: none; }
.editor-sidebar-body { flex: 1; overflow-y: auto; padding: 8px 0 24px; }

.editor-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor-header-actions .btn-primary,
.editor-header-actions .btn-outline,
.editor-header-actions .btn-ghost { padding: 8px 12px; font-size: 10px; }

/* Trash — a small dropdown off the header button, listing soft-deleted rows
   for this week with a Restore action on each. */
.trash-dd { position: relative; }
#editor-trash-btn.has-items { color: var(--danger); border-color: var(--danger); }
.trash-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: 300px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.trash-panel.hidden { display: none; }
.trash-empty { padding: 16px; font-size: 12px; color: var(--text3); font-style: italic; text-align: center; }
.trash-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.trash-item:last-child { border-bottom: none; }
.trash-item-text {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trash-restore-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  color: var(--gold-dim);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
}
.trash-restore-btn:hover { background: var(--surface3); border-color: var(--gold); }

.sidebar-section { padding: 10px 0; border-bottom: 1px solid var(--border); }
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  margin-bottom: 2px;
}
.sidebar-count { font-size: 11px; color: var(--text3); font-weight: 600; }

.sidebar-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 20px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s;
}
.sidebar-item:hover { background: var(--surface2); }
.sidebar-item.active { background: #FBF8F3; border-left-color: var(--gold); }
.drag-handle { cursor: grab; color: var(--text3); user-select: none; }
.sidebar-item .drag-handle { flex-shrink: 0; margin-top: 1px; }
.sidebar-item .row-card-lock { flex-shrink: 0; margin-top: 1px; }
.sidebar-item-num {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
  min-width: 14px;
}
.sidebar-item-text { min-width: 0; }
.sidebar-item-brief {
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sidebar-item-meta {
  font-size: 10px;
  color: var(--text3);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-more-toggle {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 20px 6px 42px;
  background: none;
  border: none;
  color: var(--gold-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-more-toggle:hover { text-decoration: underline; }

.sidebar-item.dragging { opacity: 0.4; }
.sidebar-item.drag-over-top { box-shadow: inset 0 2px 0 var(--gold); }
.sidebar-item.drag-over-bottom { box-shadow: inset 0 -2px 0 var(--gold); }
.sidebar-section-header.drag-over-bottom { box-shadow: inset 0 -2px 0 var(--gold); }
.sidebar-retag-hint {
  font-size: 10px;
  color: var(--gold-dim);
  font-weight: 700;
  padding: 4px 20px;
  background: #FBF4E4;
}

/* ── Row Editor: main content ───────────────────────────────────── */
.editor-main { flex: 1; min-width: 0; padding: 40px 32px 80px; }
#editor-cards { max-width: 1220px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
#editor-error {
  max-width: 1220px;
  margin: 0 auto 20px;
  padding: 14px 20px;
  background: #FBF0EE;
  border-left: 4px solid var(--danger);
  color: var(--danger);
  font-size: 13px;
}

.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  scroll-margin-top: 24px;
}
.row-card.card-highlight { border-color: var(--gold); }

.row-card-financial { border-left: 3px solid var(--gold); }

.row-card-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface3);
}
.row-card-num { font-size: 11px; color: var(--text3); font-weight: 700; }
.row-card-lock { display: inline-flex; align-items: center; color: var(--text3); }
.row-card-spacer { flex: 1; }
.row-card-delete {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px 6px;
  border-radius: var(--radius);
}
.row-card-delete:hover { opacity: 1; background: var(--surface2); }
.editor-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 120px;
}
.editor-select:hover { border-color: var(--gold); }
.editor-select:focus { border-color: var(--gold); outline: none; }

.row-card-body { display: flex; gap: 28px; padding: 20px 24px; }
.row-card-body.financial-body { display: block; }
.msg-block { flex: 0 0 58%; min-width: 0; }
.details-en-block { flex: 1; min-width: 0; }
.details-en-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.msg-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.msg-seqlabel { font-size: 11px; color: var(--gold-dim); font-weight: 600; letter-spacing: 0.03em; }

/* Click-to-edit tag: the pill in the card header opens a dropdown of the 4
   valid tags — same retag effect as dragging the card into another section,
   just without needing to drag. */
.tag-edit-dd { position: relative; display: inline-flex; }
.tag-edit-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.tag-edit-caret { color: var(--text3); font-size: 9px; }
.tag-edit-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 0;
}
.tag-edit-panel.hidden { display: none; }
.tag-edit-option { padding: 7px 12px; cursor: pointer; }
.tag-edit-option:hover { background: var(--surface3); }
.tag-edit-option.selected { background: var(--surface2); }

.msg-section {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
}
.msg-section-label {
  flex-shrink: 0;
  width: 72px;
  font-size: 12px;
  color: var(--text3);
  margin-top: 7px;
  white-space: nowrap;
}
.msg-section-fields { flex: 1; display: flex; gap: 6px; min-width: 0; }
.msg-section-fields .auto-grow-input { flex: 1; min-width: 0; }
.msg-section-fields .brand-combo { flex: 1; min-width: 0; position: relative; }
.msg-section-fields .brand-combo .auto-grow-input { width: 100%; }

/* Brand EN type-ahead dropdown (Row Editor) — same look as the Archive
   filters' search dropdown (.filter-dd-panel/.ms-item) for visual consistency. */
.brand-combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand-combo-list.hidden { display: none; }
.brand-combo-item { padding: 7px 10px; font-size: 12px; cursor: pointer; }
.brand-combo-item:hover { background: var(--surface3); }
.brand-combo-item small { display: block; color: var(--text3); font-size: 10px; margin-top: 1px; }
.msg-section-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
  opacity: 0.55;
  padding: 6px 2px;
}
.msg-section-remove:hover { opacity: 1; }
.msg-section-add {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--gold-dim);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.55;
  padding: 6px 2px;
}
.msg-section-add:hover { opacity: 1; }
.msg-section-content { padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border); }

/* Financial card's 数据来源 line — same position as an editable field but
   plain static text, since it's identical every week and never stored as
   editable text (see wecom_builder.compose_financial_wecom). */
.msg-section-fixed-value {
  flex: 1;
  padding: 5px 6px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text3);
  font-style: italic;
}

/* Shared auto-growing plain-text field style used throughout the editor */
.auto-grow-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 11.5px;
  line-height: 1.55;
  padding: 3px 6px;
  border-radius: var(--radius);
  resize: none;
  overflow: hidden;
}
.auto-grow-input:hover { background: var(--surface2); }
.auto-grow-input:focus { background: var(--surface2); border-color: var(--gold); outline: none; }
.msg-brief { font-weight: 600; color: var(--navy); font-size: 12.5px; }

/* ── Preview All Messages overlay ───────────────────────────────── */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(26, 30, 46, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.preview-overlay.hidden { display: none; }
.preview-overlay-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 720px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}
.preview-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-overlay-header h2 { font-family: var(--font-head); font-size: 22px; font-weight: 500; color: var(--navy); }
.preview-overlay-body { overflow-y: auto; padding: 8px 24px; }
.preview-message-card { padding: 16px 0; border-bottom: 1px solid var(--border); }
.preview-message-card:last-child { border-bottom: none; }
.preview-message-seq { font-size: 11px; color: var(--gold-dim); font-weight: 700; margin-bottom: 6px; letter-spacing: 0.03em; }
.preview-message-body { font-size: 12.5px; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

/* ── Recent Weeks (Generate tab) ─────────────────────────────────── */
#recent-weeks-list { display: flex; flex-direction: column; }
.recent-week-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.recent-week-row:last-child { border-bottom: none; }

/* ── Send tab ────────────────────────────────────────────────────── */
.send-hint {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.send-upload-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

/* ── Unverified Brands (Import tab) ─────────────────────────────── */
.unverified-brands-card.hidden { display: none; }
.unverified-brands-title {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 500;
  color: var(--navy);
}
.unverified-brands-title span { color: var(--gold-dim); font-family: var(--font-body); font-size: 13px; margin-left: 8px; }
.unverified-brand-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.unverified-brand-item:last-child { border-bottom: none; }
.unverified-brand-en { flex: 0 0 140px; font-weight: 600; color: var(--text); font-size: 13px; }
.unverified-brand-field {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--font-body);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.unverified-brand-field:focus { border-color: var(--gold); outline: none; }
.unverified-brand-field::placeholder { color: var(--text3); }
.unverified-confirm-btn { flex-shrink: 0; padding: 8px 14px; font-size: 10px; }
.preview-week-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preview-week-row input {
  width: 180px;
}

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}
.preview-count { display: flex; align-items: baseline; gap: 10px; }
.count-num {
  font-family: var(--font-head);
  font-size: 44px;
  font-weight: 300;
  color: var(--navy);
  line-height: 1;
}
.count-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.btn-send { padding: 13px 36px; }

#messages-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 24px;
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.message-card {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 28px;
  font-size: 13px;
  white-space: pre-wrap;
  line-height: 1.85;
  color: var(--text);
}
.message-card:last-child { border-bottom: none; }
.message-card:nth-child(even) { background: var(--surface2); }
.msg-num {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 10px;
  display: block;
}

/* Send progress box */
#send-progress-box { padding: 24px 32px; }

#send-progress-bar-wrap {
  height: 3px;
  background: var(--border);
  margin: 16px 0;
  overflow: hidden;
}
#send-progress-bar {
  height: 100%;
  background: var(--gold);
  width: 0%;
  transition: width 0.4s ease;
}

#send-progress-log {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}
.send-log-line {
  font-size: 12px;
  font-family: 'Courier New', monospace;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  line-height: 1.5;
}
.send-log-line.slog-ok   { color: var(--success); }
.send-log-line.slog-err  { color: var(--danger); }
.send-log-line.slog-warn { color: var(--warn); }

#send-result {
  margin-top: 16px;
  padding: 16px 24px;
  font-size: 13px;
  font-weight: 500;
  border-left: 4px solid;
}
#send-result.success { background: #EEF8F2; border-color: var(--success); color: var(--success); }
#send-result.error   { background: #FBF0EE; border-color: var(--danger); color: var(--danger); }

/* ── Confirm overlay ─────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,30,46,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--gold);
  padding: 48px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(26,30,46,0.2);
}
.confirm-icon {
  color: var(--warn);
  margin-bottom: 16px;
}
.confirm-dialog h2 {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  color: var(--navy);
  margin-bottom: 14px;
}
.confirm-dialog p {
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 32px;
  font-size: 13px;
}
.confirm-actions { display: flex; gap: 12px; justify-content: center; }

/* ── Utility ─────────────────────────────────────────────────────── */
.hidden { display: none !important; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface3); }
::-webkit-scrollbar-thumb { background: var(--border-dark); }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
