:root {
  /* Abel brand palette — restrained, professional trader's desk
     #283044 太空靛藍 / #78A1BB 鋼藍 / #EBF5EE 薄荷奶油
     #BFA89E 卡其米色 / #8B786D 灰褐色 */
  --bg: #21293c;                /* deeper than 太空靛藍 to push surfaces forward */
  --surface: #2b3548;
  --surface-2: #354158;
  --surface-3: #404d66;
  --border: #3b4763;
  --border-strong: #4a5573;
  --text: #EBF5EE;
  --text-dim: #c4d4cd;           /* slightly muted variant of 薄荷奶油 */
  --muted: #78A1BB;
  --muted-2: #5b7a90;            /* deeper 鋼藍 for tertiary text */
  --accent: #BFA89E;             /* 卡其米色 — only on CTA + highlights */
  --accent-hover: #d4bfb1;
  --accent-dim: rgba(191, 168, 158, 0.12);
  --success: #4ade80;
  --warning: #facc15;
  --danger: #f87171;
  --long: #4ade80;
  --short: #f87171;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 1px 0 rgba(255, 255, 255, 0.03), 0 2px 6px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', 'Noto Sans TC', system-ui, -apple-system, "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  text-rendering: optimizeLegibility;
}

/* Tabular numerals for all numeric displays (prices, percentages, times) */
.mono, input[type="number"], .price-cell .value, .price-cell .value-dual,
.timeline-time, .strategy-prices, td.distance-cell {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Mono font for precise data (only where it improves alignment) */
.mono, td.distance-cell, .timeline-time {
  font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Consolas, monospace;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.hint { color: var(--muted); font-size: 12px; font-weight: normal; }

button { cursor: pointer; font-family: inherit; }
input, select, textarea {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
input:hover, select:hover, textarea:hover {
  border-color: var(--border-strong);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.28);
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
textarea { width: 100%; resize: vertical; line-height: 1.6; }
input[type="number"], input[type="text"], input[type="time"] { width: 100%; }

.primary-btn {
  background: var(--accent);
  color: #283044;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.primary-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.secondary-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.secondary-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.danger-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.danger-btn:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: var(--danger);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  padding: 8px 12px;
}

.new-journal-btn {
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
}
.new-journal-btn img {
  width: 26px;
  height: 26px;
  display: block;
}
.new-journal-btn:hover img {
  opacity: 0.85;
}

/* ===== Layout ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.topbar-title { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.topbar-title #header-date {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.topbar-title #header-time {
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--muted);
}
.topbar-subline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  cursor: help;
  flex-shrink: 0;
  vertical-align: middle;
}
.status-dot.active { background: #4ade80; box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2); }
.status-dot.archived { background: #94a3b8; }
.badge {
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.active { background: var(--success); color: #283044; }
.badge.archived { background: var(--muted); color: #283044; }

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* On narrow screens drop the icon row to a second line so the date never wraps */
@media (max-width: 500px) {
  .topbar-actions {
    flex-basis: 100%;
    margin-left: 0;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }
}
.topbar-actions .primary-btn { padding: 6px 12px; font-size: 13px; }

.topbar-fields {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-fields .inline-field { font-size: 12px; }
.topbar-fields .inline-field input[type="text"] { width: 110px; }
.topbar-fields .inline-field select { padding: 4px 8px; }
.topbar-fields[hidden] { display: none; }

.key-price-input {
  width: 110px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 4px;
}
.key-price-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.layout {
  display: block;
  min-height: calc(100vh - 53px);
}

.sidebar {
  position: fixed;
  top: var(--topbar-h, 53px);
  left: 0;
  width: 240px;
  height: calc(100vh - var(--topbar-h, 53px));
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  overflow-y: auto;
  transition: transform 0.2s;
  z-index: 5;
}
.content { transition: margin-left 0.2s; }

/* Desktop default: sidebar visible, content offset */
@media (min-width: 769px) {
  .sidebar { transform: translateX(0); }
  .content { margin-left: 240px; }
  body.sidebar-toggled .sidebar { transform: translateX(-100%); }
  body.sidebar-toggled .content { margin-left: 0; }
}

/* Mobile default: sidebar hidden; toggle slides it in */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .content { margin-left: 0; }
  body.sidebar-toggled .sidebar { transform: translateX(0); }
}
.sidebar-section { margin-bottom: 28px; }
.sidebar-heading {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 10px;
  letter-spacing: 0.14em;
  font-weight: 700;
  padding: 0 8px;
}
.journal-list { list-style: none; padding: 0; margin: 0; }
.journal-list li {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 1px;
  color: var(--text-dim);
  position: relative;
  transition: color 0.12s, background 0.12s;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.journal-list li:hover { background: var(--surface); color: var(--text); }
.journal-list li.active {
  background: var(--surface);
  color: var(--accent);
}
.journal-list li.active::before {
  content: '';
  position: absolute;
  left: -1px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-width: 1200px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}
.card-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 12px;
  text-transform: uppercase;
  font-family: 'Plus Jakarta Sans', 'Noto Sans TC', sans-serif;
}
/* Chinese headings shouldn't be uppercase; revert when there's CJK content */
.card-header h2:lang(zh), .card-header h2 { text-transform: none; }

.sync-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.sync-btn:hover { background: var(--accent); color: #283044; }
.sync-btn:disabled { opacity: 0.6; cursor: wait; }
.sync-btn .sync-icon {
  display: inline-block;
  font-size: 14px;
  line-height: 1;
}
.sync-btn.spinning .sync-icon {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.actions-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.inline-field input[type="text"] { width: 140px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-2 h3 { margin: 0 0 8px 0; font-size: 14px; color: var(--muted); }

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}
.data-table th { color: var(--muted); font-weight: normal; }

.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; }

/* Close-price row (editable) */
.close-price-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.close-price-row label { white-space: nowrap; }
.close-price-row input { max-width: 140px; }

/* Editable volatility fields */
.volatility-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.volatility-fields .vol-field {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
  align-items: start;
}
.volatility-fields .vol-field label {
  color: var(--muted);
  font-size: 12px;
  padding-top: 6px;
  white-space: nowrap;
}
.volatility-fields .vol-field input,
.volatility-fields .vol-field textarea {
  font-size: 13px;
}

.open-price-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.open-price-row input { width: 140px; }
.gap-status {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-2);
}
.gap-status.up { background: rgba(74,222,128,0.2); color: var(--long); }
.gap-status.down { background: rgba(248,113,113,0.2); color: var(--short); }
.gap-status.none { color: var(--muted); }
.gap-warnings {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gap-warning {
  background: rgba(250,204,21,0.1);
  border-left: 3px solid var(--warning);
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 4px;
}
.gap-warning .pct { color: var(--warning); font-weight: 600; }

.us-callback-row {
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(56, 189, 248, 0.1);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 13px;
}
.us-callback-row .pct { color: var(--accent); font-weight: 600; }

.open-price-sync-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.linked-events-editor { margin-top: 10px; }
.linked-events-editor h4 { margin: 0 0 6px 0; font-size: 13px; color: var(--muted); }
.linked-event-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
  align-items: center;
}
.linked-event-row .actions { display: flex; gap: 4px; }
.linked-event-row .actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.strategy-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.strategy-checkbox-list label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding: 2px;
}
.strategy-checkbox-list input { width: auto; }

.entry-zone-row {
  margin-top: 12px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.entry-zone-row label { display: block; margin-bottom: 6px; font-weight: 600; }
.entry-zone-input { display: flex; align-items: center; gap: 6px; }
.entry-zone-input input { width: 100px; font-size: 16px; }

.persistence-rules {
  margin-top: 12px;
  background: var(--surface);
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.persistence-rules summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  user-select: none;
}
.persistence-rules .rules-content {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.price-cell.entry-price-spread {
  background: rgba(30, 58, 138, 0.18);
  border-color: rgba(30, 58, 138, 0.5);
}
.price-cell.lot-size {
  background: rgba(191, 168, 158, 0.1);
  border-color: rgba(191, 168, 158, 0.45);
}
.price-cell .value-dual {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 500;
  margin-top: 2px;
}

#strategy-text-output {
  font-family: 'Plus Jakarta Sans', 'Noto Sans TC', monospace;
  font-size: 13px;
  line-height: 1.7;
  background: var(--surface-2);
}

.last-bar { margin-top: 12px; }
.last-bar h4 { margin: 0 0 4px 0; font-size: 13px; color: var(--muted); }

.paste-block {
  margin-top: 16px;
  background: var(--surface-2);
  padding: 10px;
  border-radius: 6px;
}
.paste-block summary { cursor: pointer; user-select: none; }
.paste-block textarea { margin-top: 8px; font-family: ui-monospace, monospace; font-size: 12px; }
.action-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

.block { margin-top: 16px; }
.block label { display: block; margin-bottom: 4px; font-weight: 600; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* ===== Reference notes (collapsible pre-market memo) ===== */
.reference-notes {
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.reference-notes summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
  letter-spacing: 0.02em;
}
.reference-notes summary:hover { color: var(--accent); }
.reference-notes[open] summary { color: var(--accent); margin-bottom: 8px; }
.reference-content { font-size: 13px; line-height: 1.7; padding-left: 4px; }
.reference-content h4 {
  margin: 10px 0 4px 0;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.reference-content h4:first-child { margin-top: 0; }
.reference-content ol {
  margin: 0 0 6px 0;
  padding-left: 22px;
  color: var(--text-dim);
}
.reference-content li { padding: 1px 0; }
.reference-content strong { color: var(--text); font-weight: 700; }

/* ===== Strategy cards ===== */
.strategy-list { display: flex; flex-direction: column; gap: 12px; }
.strategy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 14px 18px;
  border-left: 3px solid var(--status-color, var(--border-strong));
  transition: opacity 0.15s, border-color 0.15s;
  position: relative;
}
.strategy-card:hover {
  border-color: var(--border-strong);
  border-left-color: var(--status-color, var(--border-strong));
}
.strategy-card.dragging {
  opacity: 0.4;
}
.strategy-card.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.drag-handle {
  cursor: grab;
  user-select: none;
  color: var(--muted);
  padding: 0 4px;
  font-size: 18px;
}
.drag-handle:active { cursor: grabbing; }
.direction-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  margin-left: 8px;
  letter-spacing: 0.05em;
  vertical-align: 2px;
}
.direction-badge.long {
  background: rgba(74, 222, 128, 0.12);
  color: var(--long);
  border: 1px solid rgba(74, 222, 128, 0.3);
}
.direction-badge.short {
  background: rgba(248, 113, 113, 0.12);
  color: var(--short);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  background: var(--status-color, var(--border));
  color: #1a2030;
  letter-spacing: 0.02em;
  text-transform: none;
}
.strategy-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.strategy-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.005em;
}
.strategy-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.strategy-prices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.price-cell {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.price-cell.stop-loss {
  background: rgba(153, 27, 27, 0.18);
  border-color: rgba(153, 27, 27, 0.5);
}
.price-cell.entry-price {
  background: rgba(30, 58, 138, 0.18);
  border-color: rgba(30, 58, 138, 0.5);
}
.price-cell .label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.price-cell.stop-loss .label, .price-cell.entry-price .label { color: var(--text-dim); }
.price-cell .value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 15px;
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: -0.005em;
}

.strategy-status-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.strategy-actions { display: flex; gap: 6px; }
.strategy-actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}

.linked-events {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
}
.linked-events .label { color: var(--muted); margin-bottom: 4px; }
.linked-events ul { list-style: none; padding: 0; margin: 0; }
.linked-events li { padding: 2px 0; }

/* ===== Timeline ===== */
.timeline-list { display: flex; flex-direction: column; gap: 6px; }
.timeline-row {
  display: grid;
  grid-template-columns: 60px 100px 1fr auto;
  gap: 10px;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  align-items: center;
}
.timeline-time { font-family: ui-monospace, monospace; color: var(--accent); }
.timeline-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  align-self: start;
  font-weight: 500;
}
.timeline-desc { font-size: 13px; }
.timeline-row.has-link { border-left: 3px solid var(--accent); }
.timeline-strategy {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ===== Screenshot grid ===== */
.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.screenshot-tile {
  position: relative;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.screenshot-tile img { width: 100%; height: 120px; object-fit: cover; display: block; }
.screenshot-tile .label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  padding: 4px 6px;
}
.screenshot-tile .delete {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 24px; height: 24px;
}

/* ===== Dialog ===== */
.dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 480px;
  width: 90%;
}
.dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog form { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dialog h3 { margin: 0 0 8px 0; }
.dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.readonly-row {
  background: var(--surface-2);
  padding: 8px;
  border-radius: 4px;
  font-size: 13px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.dialog-subhead {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 4px;
}
.entry-condition-row {
  display: grid !important;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 6px;
}
.entry-condition-row input[type="checkbox"] { margin-top: 8px; width: auto; }
.entry-condition-row textarea {
  font-size: 13px;
  line-height: 1.5;
}

/* Strategy card entry-condition rows */
.strategy-conditions {
  margin: 10px 0 6px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.strategy-condition {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  font-size: 12px;
  background: var(--surface);
  border-radius: 4px;
  padding: 6px 8px;
}
.strategy-condition input[type="checkbox"] {
  margin-top: 2px;
  width: auto;
}
.strategy-condition .text { white-space: pre-line; word-break: break-word; }
.strategy-condition .text.empty { color: var(--muted); font-style: italic; }

/* ===== Collapsed strategy card (破位 / 打平 / 未進入掛單領域) ===== */
.strategy-card .collapse-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.strategy-card .collapse-btn .when-collapsed { display: none; }
.strategy-card .collapse-btn .when-expanded { display: inline; }
.strategy-card.collapsed .collapse-btn .when-collapsed { display: inline; }
.strategy-card.collapsed .collapse-btn .when-expanded { display: none; }

.strategy-card.collapsed .strategy-prices,
.strategy-card.collapsed .linked-events,
.strategy-card.collapsed .strategy-notes-display {
  display: none;
}
.strategy-card.collapsed .strategy-condition:not(.is-checked) {
  display: none;
}
/* Hide the whole conditions block if every condition is unchecked (nothing left to show) */
.strategy-card.collapsed .strategy-conditions:not(:has(.strategy-condition.is-checked)) {
  display: none;
}

/* ===== Bell + Notifications popover ===== */
.bell-btn { position: relative; }
.bell-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--danger);
  color: #283044;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
}

.notifications-popover {
  position: absolute;
  top: 100%; right: 16px;
  width: 320px;
  max-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  z-index: 20;
  margin-top: 4px;
}
.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
}
.link-btn {
  background: transparent;
  color: var(--accent);
  border: none;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.notification-row {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
}
.notification-row:last-child { border-bottom: none; }
.notification-row .notif-top {
  font-size: 11px;
  font-weight: 700;
  color: #fb923c;
  letter-spacing: 0.5px;
}
.notification-row .notif-top:empty { display: none; }
.notification-row .notif-name { grid-column: 1 / -1; font-weight: 600; font-size: 13px; }
.notification-row .notif-time { font-size: 11px; color: var(--muted); justify-self: end; }
.notification-row .notif-msg { grid-column: 1 / -1; font-size: 13px; color: var(--text); white-space: pre-line; }
.notification-row .dismiss { grid-column: 2; justify-self: end; font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer; }
.notification-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ===== Floating notification toasts (bottom-right) ===== */
.notification-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  max-width: 360px;
}
.notification-toast {
  background: var(--surface);
  border: 2px solid #fb923c;
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.25), 0 6px 16px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.2s ease-out;
}
.notification-toast .top-label {
  font-size: 11px;
  font-weight: 700;
  color: #fb923c;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  text-transform: uppercase;
}
.notification-toast .top-label:empty { display: none; }
.notification-toast .name { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--text); }
.notification-toast .msg { font-size: 13px; white-space: pre-line; }
.notification-toast .close {
  float: right;
  background: none;
  border: none;
  color: #fb923c;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  margin-left: 8px;
  line-height: 1;
  padding: 0 4px;
}
.notification-toast .close:hover { color: #ffffff; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== Reminders settings list ===== */
.dialog-wide { max-width: 640px !important; }
.dialog-pad { padding: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dialog-head h3 { margin: 0; }

.reminders-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.reminders-tabs .rtab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.reminders-tabs .rtab:hover { color: var(--text); }
.reminders-tabs .rtab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.reminders-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  max-height: 50vh;
  overflow-y: auto;
}

.topbar-fields .inline-field select#field-module { min-width: 130px; }
.reminder-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  align-items: center;
}
.reminder-row.disabled { opacity: 0.5; }
.reminder-row .meta { font-size: 12px; color: var(--muted); }
.reminder-row .name { font-weight: 600; }
.reminder-row .actions { display: flex; gap: 4px; }
.reminder-row .actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.reminder-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 13px;
}

/* ===== Timeframe multi-select chips ===== */
.timeframe-multi {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.timeframe-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.timeframe-chip input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.timeframe-chip:has(input:checked) {
  background: var(--accent);
  color: #283044;
  border-color: var(--accent);
}

/* ===== Notes (conditional ⓘ icon) ===== */
.note-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fb923c;
  color: #283044;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 6px;
  border: none;
  position: relative;
  flex-shrink: 0;
  font-family: 'Times New Roman', serif;
  font-style: italic;
}
.note-icon:hover {
  background: #fdba74;
}
.note-icon .count-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  font-size: 9px;
  background: var(--danger);
  color: #fff;
  border-radius: 8px;
  padding: 0 4px;
  min-width: 12px;
  font-style: normal;
  font-family: var(--font-family, sans-serif);
}

.note-popover {
  /* uses .dialog base; the orange accent border distinguishes it */
  max-width: 520px;
  width: 92%;
  border: 2px solid #fb923c !important;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.25), 0 8px 24px rgba(0, 0, 0, 0.5);
}
.note-popover-body {
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px 0;
}
.note-popover .note-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.note-popover .note-entry:last-child { border-bottom: none; padding-bottom: 0; }
.note-popover .note-entry:first-child { padding-top: 0; }
.note-popover .note-entry .note-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.note-popover .note-entry .note-title {
  font-weight: 600;
  color: #fb923c;
  font-size: 13px;
}
.note-popover .note-entry .edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}
.note-popover .note-entry .edit-btn:hover {
  background: #fb923c;
  color: #283044;
  border-color: #fb923c;
}
.note-popover .note-entry .note-body {
  white-space: pre-line;
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
}

/* ===== Note condition editor rows ===== */
.note-conditions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 8px 0;
}
.note-condition-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 6px;
  align-items: center;
  background: var(--surface-2);
  padding: 6px;
  border-radius: 4px;
}
.note-condition-row .field-select,
.note-condition-row .op-select,
.note-condition-row .val-input {
  font-size: 12px;
  padding: 4px 6px;
}
.note-condition-row .multi-values {
  font-size: 12px;
  min-height: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
}
.note-condition-row .multi-values .chip {
  background: var(--accent);
  color: #283044;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.note-condition-row .multi-values .chip button {
  background: none;
  border: none;
  color: #283044;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.note-condition-row .remove-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 100;
}
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .card { padding: 12px; }

  /* Timeline on mobile: stacked layout, full-width description */
  .timeline-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "time type actions"
      "content content content";
    gap: 6px 10px;
    padding: 10px;
    align-items: center;
  }
  .timeline-row .timeline-time {
    grid-area: time;
    font-size: 14px;
    font-weight: 600;
  }
  .timeline-row .timeline-type {
    grid-area: type;
    font-size: 11px;
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    justify-self: start;
  }
  .timeline-row .timeline-content {
    grid-area: content;
    line-height: 1.5;
    word-break: break-word;
  }
  .timeline-row .strategy-actions {
    grid-area: actions;
    justify-self: end;
  }
}
