:root {
  --bg: #f2ede2;
  --card: #fdfbf5;
  --card-soft: #f7f3e9;
  --ink: #2f3a2e;
  --ink-soft: #6b715f;
  --green: #3e4a3a;
  --green-hover: #4d5c48;
  --accent: #b06b3c;
  --line: #e3dcc9;
  --red: #b0483c;
  --radius: 14px;
  font-size: 15px;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  line-height: 1.65;
}

.hidden { display: none !important; }

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

/* ---------- sidebar ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #ece6d6;
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 22px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--green); color: #f5f1e4;
  display: flex; align-items: center; justify-content: center;
  font-family: Georgia, serif; font-size: 20px; font-style: italic;
}
.brand-name { font-weight: 700; letter-spacing: 1px; }
.brand-sub { font-size: 11px; color: var(--ink-soft); letter-spacing: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  padding: 10px 14px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: 15px;
}
.nav-item:hover { background: #e2dbc8; }
.nav-item.active { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.06); font-weight: 700; }

.sidebar-foot { margin-top: auto; padding: 12px 8px; font-size: 12px; }
.conn-badge { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.conn-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #b8b2a0; }
.conn-badge.on .dot { background: #4c8a4c; }
.conn-badge.on { color: #37613a; }
.conn-sub { color: var(--ink-soft); margin-top: 4px; }

/* ---------- main ---------- */
.main { flex: 1; padding: 46px 56px 90px; max-width: 1150px; }

.eyebrow {
  font-size: 12px; letter-spacing: 3px; color: var(--accent);
  font-weight: 700; margin-bottom: 10px;
}
h1 {
  font-family: "Noto Serif TC", Georgia, serif;
  font-size: 34px; font-weight: 700; margin-bottom: 10px;
}
h2 { font-size: 18px; }
.lead { color: var(--ink-soft); margin-bottom: 26px; }
.section-title { margin: 34px 0 14px; font-family: "Noto Serif TC", Georgia, serif; }

/* ---------- search ---------- */
.searchbar {
  display: flex; gap: 10px; background: var(--card);
  padding: 10px; border-radius: var(--radius); border: 1px solid var(--line);
  max-width: 720px;
}
.searchbar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; padding: 6px 10px; font-family: inherit;
}
.quick-tags {
  margin: 12px 2px 20px; font-size: 13px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.qt-theme { font-weight: 700; color: var(--ink); }
.pager {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin: 20px 0 6px; flex-wrap: wrap;
}
.pager-info { font-size: 13px; color: var(--ink-soft); min-width: 150px; text-align: center; }
.tag {
  display: inline-block; margin: 0 4px; padding: 2px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 99px;
  cursor: pointer; color: var(--ink);
}
.tag:hover { border-color: var(--green); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 20px; border-radius: 10px; cursor: pointer;
  font-size: 15px; font-family: inherit;
}
.btn:hover { border-color: var(--green); }
.btn.primary { background: var(--green); color: #f5f1e4; border-color: var(--green); }
.btn.primary:hover { background: var(--green-hover); }
.btn.big { padding: 13px 30px; font-size: 16px; }
.btn.small { padding: 5px 14px; font-size: 13px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }

/* ---------- product grid ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px; margin-top: 8px;
}
.product {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; position: relative; transition: box-shadow .15s;
}
.product:hover { box-shadow: 0 3px 12px rgba(0,0,0,.07); }
.product.selected { border: 2px solid var(--green); background: #f2f4ec; }
.product .p-img {
  width: 100%; height: 120px; border-radius: 8px; background: var(--card-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; margin-bottom: 10px; overflow: hidden;
}
.product .p-img img { width: 100%; height: 100%; object-fit: cover; }
.product .p-name { font-size: 14px; font-weight: 600; min-height: 44px; }
.product .p-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.product .p-price { font-weight: 700; color: var(--accent); }
.product .p-cat { font-size: 11px; color: var(--ink-soft); }
.product .p-check {
  position: absolute; top: 10px; right: 10px; width: 24px; height: 24px;
  border-radius: 50%; border: 1.5px solid var(--line); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: transparent;
}
.product.selected .p-check { background: var(--green); border-color: var(--green); color: #fff; }
.rocket-badge {
  display: inline-block; font-size: 10px; background: #eef; color: #3949ab;
  padding: 1px 7px; border-radius: 99px; margin-left: 6px;
}

/* ---------- tray ---------- */
.tray {
  position: sticky; bottom: 16px; margin-top: 22px;
  background: var(--green); color: #f0ecdc; border-radius: var(--radius);
  padding: 14px 22px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 6px 22px rgba(0,0,0,.18);
}
.tray-actions { display: flex; gap: 14px; align-items: center; }
.tray-date { font-size: 13px; }
.tray-date input { margin-left: 6px; border: none; border-radius: 8px; padding: 6px 8px; font-family: inherit; }
.tray .btn.primary { background: #f0ecdc; color: var(--green); border-color: #f0ecdc; font-weight: 700; }

/* ---------- content cards ---------- */
.cards { display: flex; flex-direction: column; gap: 14px; }
.content-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.cc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cc-product { font-weight: 700; font-size: 14px; }
.cc-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.cc-status { font-size: 12px; padding: 3px 12px; border-radius: 99px; white-space: nowrap; }
.st-draft { background: #f3ead8; color: #8a6d2f; }
.st-scheduled { background: #e3ecdf; color: #3f6a42; }
.st-published { background: #dfe8f2; color: #33567c; }
.st-failed { background: #f2dfdd; color: #93392f; }
.cc-text, .cc-comment {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card-soft); padding: 12px; font-family: inherit; font-size: 14px;
  resize: vertical; min-height: 110px; line-height: 1.7;
}
.cc-comment { min-height: 64px; background: #f2f4ec; }
.cc-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  margin: 14px 0 6px;
}
.btn.tiny { padding: 2px 10px; font-size: 12px; }
.cc-link { font-size: 12px; margin-top: 8px; color: var(--ink-soft); word-break: break-all; }
.cc-link a { color: #33567c; }
.cc-foot { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.cc-foot .time-input { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-family: inherit; }
.cc-foot .spacer { flex: 1; }
.engine-tag { font-size: 11px; color: var(--ink-soft); }

/* ---------- stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 10px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px;
}
.stat .s-label { font-size: 12px; color: var(--ink-soft); }
.stat .s-value { font-size: 26px; font-weight: 700; font-family: Georgia, serif; }
.stat .s-note { font-size: 11px; color: var(--ink-soft); }

/* ---------- misc ---------- */
.notice {
  background: #eef0e4; border: 1px solid #dfe2cd; border-radius: 10px;
  padding: 10px 16px; font-size: 13px; margin: 10px 0; color: #55603f;
}
.notice.error { background: #f6e7e4; border-color: #e8cbc5; color: var(--red); }
.notice.ok { background: #e6efe4; border-color: #cfe0cb; color: #37613a; }

.filter-row { display: flex; gap: 8px; margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 99px;
  padding: 5px 16px; cursor: pointer; font-size: 13px; font-family: inherit; color: var(--ink);
}
.chip.active { background: var(--green); color: #f0ecdc; border-color: var(--green); }

.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 26px; margin-bottom: 22px; max-width: 720px;
}
.panel h2 { font-family: "Noto Serif TC", Georgia, serif; margin-bottom: 6px; }
.panel .hint { font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; }
.panel label { display: block; font-size: 13px; font-weight: 700; margin-top: 14px; }
.panel input, .panel textarea {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-family: inherit; font-size: 14px;
}
.panel code { background: var(--card-soft); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.mini { font-weight: 400; color: var(--ink-soft); font-size: 12px; }

.empty {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 34px; text-align: center; color: var(--ink-soft); font-size: 14px;
  background: rgba(255,255,255,.4);
}

.report-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; font-size: 13px; margin-top: 16px; }
.report-table th, .report-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.report-table th { background: var(--card-soft); font-size: 12px; color: var(--ink-soft); }

/* ---------- 作戰室 ---------- */
.warroom {
  margin-top: 26px; background: var(--card); border: 2px solid var(--green);
  border-radius: var(--radius); padding: 24px 26px;
  box-shadow: 0 8px 28px rgba(0,0,0,.10);
}
.wr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.wr-title { font-family: "Noto Serif TC", Georgia, serif; font-size: 20px; margin: 2px 0; }
.wr-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; }
.wr-link-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin: 16px 0;
}
.wr-link-row .wr-label { margin: 0; }
.wr-link { font-size: 14px; font-weight: 700; color: #33567c; word-break: break-all; flex: 1; min-width: 180px; }
.wr-section { margin-top: 18px; }
.wr-kw-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.wr-kw { cursor: pointer; font-size: 13px; padding: 4px 14px; }
.wr-types { margin: 8px 0 10px 20px; font-size: 14px; }
.wr-types li { margin-bottom: 6px; }
.wr-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.wr-action {
  text-align: left; background: var(--card-soft); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 14px 16px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; gap: 4px; transition: border-color .15s, box-shadow .15s;
}
.wr-action:hover { border-color: var(--green); box-shadow: 0 3px 10px rgba(0,0,0,.07); }
.wr-action b { font-size: 15px; color: var(--ink); }
.wr-action span { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.wr-patrol-opts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.wr-patrol-opts input[type="text"] {
  flex: 1; min-width: 220px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-family: inherit; font-size: 14px;
}
.wr-patrol-opts select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; }
.wr-date-row { margin-top: 14px; font-size: 13px; color: var(--ink-soft); }
.wr-date-row input { margin-left: 8px; }
.p-first {
  display: inline-block; margin-left: 6px; font-size: 11px; color: #93392f;
  background: #f6e7e4; border-radius: 99px; padding: 1px 8px; font-weight: 700;
}
#best-category { padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; font-family: inherit; font-size: 13px; background: var(--card); }

/* ---------- 海巡留言 ---------- */
.patrol-picklist { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
.patrol-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px;
}
.patrol-row.picked { border: 2px solid var(--green); background: #f2f4ec; }
.patrol-row .pr-name { flex: 1; font-size: 14px; font-weight: 600; }
.patrol-row .pr-price { color: var(--accent); font-weight: 700; white-space: nowrap; }
.patrol-set { max-width: 860px; }
.variant {
  display: flex; gap: 12px; align-items: flex-start;
  border-top: 1px dashed var(--line); padding: 12px 0;
}
.variant .v-text { flex: 1; font-size: 14px; word-break: break-all; white-space: pre-wrap; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0 4px; }
.radio { font-weight: 400 !important; font-size: 14px !important; display: flex !important; align-items: center; gap: 6px; margin-top: 4px !important; }
.radio input { width: auto !important; margin: 0 !important; }
.adv { margin-top: 14px; font-size: 13px; }
.adv summary { cursor: pointer; color: var(--ink-soft); }
.panel select {
  margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; font-family: inherit; font-size: 14px;
}

/* ---------- PIN 通行碼 ---------- */
.pin-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.pin-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 40px 44px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.12);
  display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 280px;
}
.pin-box h2 { font-family: "Noto Serif TC", Georgia, serif; }
.pin-box p { font-size: 13px; color: var(--ink-soft); }
.pin-box input {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 18px; text-align: center; letter-spacing: 4px; font-family: inherit;
}
.pin-box .btn { width: 100%; }

/* ---------- 貼網址秒轉分潤 ---------- */
.paste-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin: 4px 0 12px; max-width: 860px;
}
.paste-box .wr-label { margin: 0; white-space: nowrap; }
.paste-box input {
  flex: 1; min-width: 160px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-family: inherit; font-size: 13px;
}
#paste-title { flex: 0 1 180px; }

/* ---------- 標錯價徽章 ---------- */
.p-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  background: #f6e7e4; color: #93392f; border-radius: 99px; padding: 1px 8px; margin-left: 4px;
}

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #f5f1e4; padding: 10px 26px; border-radius: 99px;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 99;
}

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 10;
    flex-direction: column; padding: 10px 12px; gap: 8px;
  }
  .brand { padding: 0 4px 4px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; -webkit-overflow-scrolling: touch; }
  .nav-item { white-space: nowrap; padding: 8px 12px; font-size: 14px; }
  .sidebar-foot { display: none; }
  .main { padding: 22px 16px 70px; }
  h1 { font-size: 26px; }
  .tray { flex-direction: column; gap: 10px; align-items: stretch; text-align: center; }
  .cc-foot { gap: 6px; }
  .variant { flex-direction: column; gap: 8px; }
  .variant .btn { align-self: flex-end; }
}
