:root {
  --bg: #0f1923;
  --bg-card: #1a2633;
  --bg-card-hover: #223344;
  --border: #2a3a4a;
  --text: #e0e6ed;
  --text-muted: #8899aa;
  --accent: #00b4d8;
  --accent2: #0077b6;
  --warn: #f4a261;
  --danger: #e63946;
  --success: #2a9d8f;
  --radius: 10px;
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Header */
header {
  background: linear-gradient(135deg, #0a1628 0%, #1a2840 100%);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 16px;
}

header h1 { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.subtitle { font-size: 0.85rem; color: var(--text-muted); }
.header-date { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); }

main { max-width: 1440px; margin: 0 auto; padding: 20px; }

/* ===== ACTION SECTION (TOP PRIORITY) ===== */
.action-section {
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.action-count {
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
}

.action-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 10px;
}

.action-item {
  background: var(--bg-card);
  border-left: 4px solid var(--text-muted);
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: transform 0.15s;
}

.action-item:hover { transform: translateY(-2px); }
.action-item.priority-high { border-left-color: var(--danger); }
.action-item.priority-medium { border-left-color: var(--warn); }

.action-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.action-body { flex: 1; min-width: 0; }

.action-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.action-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.action-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
}

.badge-high { background: var(--danger); color: #fff; }
.badge-medium { background: var(--warn); color: #1a1a1a; }
.badge-quote { background: var(--accent2); color: #fff; }
.badge-upsell { background: var(--success); color: #fff; }
.badge-quality { background: var(--danger); color: #fff; }
.badge-competitive { background: #8338ec; color: #fff; }
.badge-price { background: var(--warn); color: #1a1a1a; }
.badge-seasonal { background: #06d6a0; color: #1a1a1a; }

/* ===== Cards & Layout ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card h2 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.card-wide { grid-column: span 1; }

.split-row:has(.card-wide) {
  grid-template-columns: 2fr 1fr;
}

/* ===== Last Order ===== */
.last-order-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.order-item-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.order-item-row:last-child { border-bottom: none; }
.order-item-name { color: var(--text); }
.order-item-qty { color: var(--accent); font-weight: 600; }

/* ===== Signal Lists ===== */
.signal-list { max-height: 240px; overflow-y: auto; }

.signal-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.signal-item:last-child { border-bottom: none; }
.signal-date { color: var(--text-muted); font-size: 0.7rem; }
.signal-text { color: var(--text); margin-top: 2px; }
.signal-empty { color: var(--text-muted); font-style: italic; font-size: 0.8rem; }

/* ===== YoY Table ===== */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }

th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}

td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg-card-hover); }

.change-up { color: var(--success); font-weight: 600; }
.change-down { color: var(--danger); font-weight: 600; }
.change-new { color: var(--accent); font-weight: 600; }

/* ===== Week Summary & Next Week Plan ===== */
.summary-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.summary-stat:last-child { border-bottom: none; }
.summary-label { color: var(--text-muted); }
.summary-value { font-weight: 700; color: var(--text); }
.summary-value.highlight { color: var(--accent); }
.summary-value.warn { color: var(--warn); }
.summary-value.danger { color: var(--danger); }

.plan-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.plan-item:last-child { border-bottom: none; }

.plan-day {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

.plan-day.mon { background: var(--accent2); }
.plan-day.tue { background: #2a9d8f; }
.plan-day.wed { background: #8338ec; }
.plan-day.thu { background: var(--warn); color: #1a1a1a; }
.plan-day.fri { background: var(--danger); }

.plan-body { flex: 1; min-width: 0; }

.plan-action {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.plan-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.plan-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
}

/* ===== Weekly Update Section ===== */
.update-section h2 { margin-bottom: 4px; }

.update-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.update-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.update-subtitle strong { color: var(--accent); }

.data-status {
  flex-shrink: 0;
  text-align: right;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-fresh { background: var(--success); color: #fff; }
.status-stale { background: var(--warn); color: #1a1a1a; }
.status-old { background: var(--danger); color: #fff; }

.status-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.update-steps {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.step {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.step-num {
  background: var(--accent2);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-text { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

.paste-area { margin-bottom: 12px; }

textarea#chat-input {
  width: 100%;
  min-height: 160px;
  background: var(--bg);
  color: var(--text);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.8rem;
  resize: vertical;
  transition: border-color 0.2s;
}

textarea#chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea#chat-input::placeholder { color: #445566; }

.paste-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.paste-info { font-size: 0.75rem; color: var(--text-muted); }

.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }

.paste-result {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-top: 8px;
}

.paste-result.success {
  background: rgba(42, 157, 143, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
}

.paste-result.error {
  background: rgba(230, 57, 70, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.hidden { display: none; }

/* ===== Charts ===== */
.price-filter { margin-bottom: 10px; }
.price-filter select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* ===== Persona (Collapsible) ===== */
.collapsible { margin-bottom: 12px; }

.collapsible-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.collapsible-header:hover { color: var(--accent); }
.toggle-icon { font-size: 1.2rem; color: var(--text-muted); }
.hidden { display: none; }

.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.persona-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.persona-block h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.persona-block ul { list-style: none; padding: 0; }
.persona-block li {
  font-size: 0.8rem;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.persona-block li:last-child { border-bottom: none; }
.persona-block .label { color: var(--text-muted); font-size: 0.7rem; }

.tag {
  display: inline-block;
  background: var(--accent2);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 7px;
  border-radius: 10px;
  margin: 1px;
}
.tag.red { background: var(--danger); }
.tag.yellow { background: var(--warn); color: #1a1a1a; }
.tag.green { background: var(--success); }

footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.7rem;
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 900px) {
  .split-row { grid-template-columns: 1fr; }
  .split-row:has(.card-wide) { grid-template-columns: 1fr; }
  .action-list { grid-template-columns: 1fr; }
  .persona-grid { grid-template-columns: 1fr; }
}
