/* Palette 5: Apricot & Coffee */
:root {
  --bg: #F7F1E8;
  --surface: #EDE2D2;
  --text: #3B2A20;
  --primary: #C65D3B;
  --accent: #E9A93B;
  --accent-ink: #8A5A12;
  --on-primary: #FFFFFF;
  --muted: #7D6656;
  --border: #DCCDB6;
  --sidebar: #3B2A20;
  --sidebar-text: #F3E9DC;
  --sidebar-hover: #4A372D;
  --good: #4F8A3C;
  --bad: #C8452F;
  --warn: #B87A12;
  --good-bg: #E4EDD8;
  --bad-bg: #F7DDD6;
  --warn-bg: #F6E6C4;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(59, 42, 32, .08);
}

:root[data-theme="dark"] {
  --bg: #1F1713;
  --surface: #2D211B;
  --text: #F3E9DC;
  --primary: #E07A57;
  --accent: #E9A93B;
  --accent-ink: #E9A93B;
  --on-primary: #1F1713;
  --muted: #BFA896;
  --border: #40312A;
  --sidebar: #150F0C;
  --sidebar-text: #F3E9DC;
  --sidebar-hover: #2D211B;
  --good: #8BBF72;
  --bad: #F08A74;
  --warn: #E9A93B;
  --good-bg: #2A3524;
  --bad-bg: #3F231C;
  --warn-bg: #3F3015;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 6px;
  background: var(--primary); color: var(--on-primary);
  font-weight: 700; font-size: 19px; letter-spacing: -1px;
  display: grid; place-items: center; position: relative; flex: none;
}
.brand-mark::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 6px;
  height: 3px; border-radius: 2px; background: var(--accent);
}
.brand-name {
  border-left: 2px solid var(--accent); padding-left: 10px;
  font-weight: 700; font-size: 15px; line-height: 1.15;
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; background: var(--sidebar); color: var(--sidebar-text);
  padding: 24px 16px; position: fixed; top: 0; bottom: 0; left: 0;
}
.sidebar .brand { padding: 0 8px 28px; }
.sidebar .brand-name { border-color: var(--primary); color: var(--sidebar-text); }
.sidebar nav a {
  display: block; padding: 10px 12px; border-radius: 10px;
  margin-bottom: 4px; font-size: 14px; opacity: .85;
}
.sidebar nav a:hover { background: var(--sidebar-hover); opacity: 1; }
.sidebar nav a.active { background: var(--primary); color: var(--on-primary); opacity: 1; font-weight: 600; }

.main { margin-left: 250px; flex: 1; padding: 28px 32px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar h1 { font-size: 24px; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600;
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(4, 1fr); }
.grid.two { grid-template-columns: 2fr 1fr; margin-top: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card h3 { font-size: 15px; margin-bottom: 12px; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 28px; font-weight: 700; margin: 6px 0; }
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover td { background: color-mix(in srgb, var(--primary) 8%, transparent); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad); }

/* ---------- Controls ---------- */
.btn {
  display: inline-block; border: 0; cursor: pointer;
  background: var(--primary); color: var(--on-primary);
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.btn:hover { filter: brightness(.95); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

input, select {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

.toolbar { display: flex; gap: 12px; margin-bottom: 16px; }
.toolbar input { max-width: 280px; }
.toolbar select { max-width: 200px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 380px; max-width: 100%; }
.login-card .brand { margin-bottom: 20px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.login-card .btn { width: 100%; margin-top: 20px; }

/* ---------- Charts ---------- */
.bars-wrap { padding-bottom: 26px; }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 220px; padding-top: 10px; }
.bar {
  flex: 1; position: relative; min-height: 4px; border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 55%, var(--surface)));
}
.bar span { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); }

.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }
.row { display: flex; justify-content: space-between; font-size: 14px; margin: 14px 0 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .grid.kpi { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { position: static; width: 100%; }
  .main { margin-left: 0; padding: 20px 16px; }
  .grid.kpi { grid-template-columns: 1fr; }
}

/* ================= App shell ================= */
.hdr {
  position: sticky; top: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.hdr-title { font-size: 18px; font-weight: 700; text-align: center; }
.hdr-right { display: flex; justify-content: flex-end; align-items: center; gap: 12px; position: relative; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 17px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--primary); }
.ava { border-radius: 50%; color: #fff; font-weight: 700; display: inline-grid; place-items: center; flex: none; letter-spacing: .02em; }
.ava-btn { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; display: grid; }
.ava-btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.menu {
  position: absolute; top: 52px; right: 0; min-width: 210px; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 8px;
}
.menu.open { display: block; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu .who b { display: block; font-size: 14px; }
.menu .who span { font-size: 12px; color: var(--muted); }
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: color-mix(in srgb, var(--primary) 14%, transparent); }

.shell {
  display: grid; grid-template-columns: 240px minmax(0, 1fr) 300px; gap: 24px;
  max-width: 1400px; margin: 0 auto; padding: 24px; align-items: start;
}

/* left nav */
.nav { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 4px; }
.nav a { padding: 11px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.nav a:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.nav a.active { background: var(--primary); color: var(--on-primary); font-weight: 700; }

/* feed */
.feed { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; margin: 0 auto; }
.post-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.post-meta { flex: 1; min-width: 0; line-height: 1.25; }
.post-meta b { font-size: 14px; }
.post-meta span { display: block; font-size: 12px; color: var(--muted); }
.post h3 { font-size: 17px; margin-bottom: 8px; }
.post p { font-size: 14px; color: var(--text); opacity: .9; }
.post-foot { display: flex; gap: 8px; margin-top: 14px; }
.chip-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.chip-btn:hover { border-color: var(--primary); color: var(--text); }
.chip-btn.on { background: color-mix(in srgb, var(--primary) 20%, transparent); border-color: var(--primary); color: var(--text); }
.badge.info { background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--accent); }

/* right: events */
.events { position: sticky; top: 88px; }
.events h3 { margin-bottom: 4px; }
.ev { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.ev:last-child { border-bottom: 0; padding-bottom: 0; }
.ev-date { width: 48px; flex: none; text-align: center; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 6px 0; }
.ev-date b { display: block; font-size: 18px; line-height: 1.1; }
.ev-date span { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.ev-info { font-size: 14px; line-height: 1.35; }
.ev-info small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .events { grid-column: 2; position: static; }
}
@media (max-width: 760px) {
  .hdr { padding: 10px 14px; }
  .hdr .brand-name { display: none; }
  .shell { grid-template-columns: 1fr; padding: 16px 14px; }
  .nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .nav a { white-space: nowrap; }
  .events { grid-column: 1; }
}

/* theme switch */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); padding: 3px; }
.seg button {
  width: 34px; height: 30px; border: 0; border-radius: 999px; background: none;
  color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--primary); color: var(--on-primary); }
.seg button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ================= Posts: composer, comments ================= */
textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px; resize: vertical;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text);
}
textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.list { display: flex; flex-direction: column; gap: 16px; }
.post-text { white-space: pre-line; }

.composer-top { display: flex; gap: 12px; align-items: flex-start; }
.composer-fields { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.composer-row { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 12px; }
.composer-row select { max-width: 180px; }

.btn.small { padding: 8px 14px; font-size: 13px; }

.cm-wrap { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.cm { display: flex; gap: 10px; padding: 6px 0; }
.cm-body { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
.cm-top b { font-size: 13px; }
.cm-top span { font-size: 12px; color: var(--muted); margin-left: 6px; }
.cm-body p { font-size: 13px; margin: 2px 0 4px; opacity: 1; }
.cm-like { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; }
.cm-like:hover { color: var(--text); }
.cm-like.on { color: var(--accent); font-weight: 700; }
.cm-more { border: 0; background: none; padding: 6px 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; }
.cm-more:hover { text-decoration: underline; }
.cm-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }
.cm-form { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.cm-form input { flex: 1; min-width: 0; }

/* country filter (guides) */
.flt {
  display: flex; justify-content: space-between; width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 0; border-radius: 10px; background: none; color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.flt:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.flt.on { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.flt span { opacity: .7; }

/* ================= Coins (effectiveness currency) ================= */
.coins {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.coins:hover { border-color: var(--primary); }
.coins small { font-size: 11px; color: var(--muted); font-weight: 600; }
.coin {
  width: 16px; height: 16px; border-radius: 50%; flex: none; display: inline-block;
  background: var(--primary);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 55%, var(--primary));
}

/* ================= Pages without right column ================= */
.shell.wide { grid-template-columns: 240px minmax(0, 1fr); }
@media (max-width: 1100px) { .shell.wide { grid-template-columns: 200px minmax(0, 1fr); } }
@media (max-width: 760px)  { .shell.wide { grid-template-columns: 1fr; } }

/* ================= Community ================= */
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.country { display: flex; align-items: center; gap: 16px; padding: 18px 20px; transition: transform .12s, border-color .12s; }
.country:hover { transform: translateY(-2px); border-color: var(--primary); }
.country b { display: block; font-size: 16px; }
.country small { color: var(--muted); font-size: 13px; }
.flag { width: 48px; height: auto; border-radius: 4px; box-shadow: 0 0 0 1px var(--border); flex: none; }

/* ================= Shop ================= */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.prod { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.prod-pic { height: 150px; display: grid; place-items: center; font-size: 56px; }
.prod-body { padding: 14px 16px 16px; }
.prod-body b { display: block; font-size: 15px; }
.prod-body p { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.price { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.price small { color: var(--muted); font-size: 12px; font-weight: 600; }

/* ================= About ================= */
.about-cover {
  height: 300px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  background: linear-gradient(135deg, var(--primary), var(--accent));
}
.about-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.about-text { margin-top: 16px; }
.about-text h2 { font-size: 20px; margin-bottom: 8px; }
.about-text h3 { font-size: 16px; margin: 18px 0 6px; }
.about-text p { font-size: 14px; line-height: 1.65; margin-bottom: 10px; }

/* ===== server-rendered shell ===== */
.ava-sm { width: 30px; height: 30px; font-size: 12px; }
.ava-md { width: 38px; height: 38px; font-size: 15px; }
.ava-lg { width: 42px; height: 42px; font-size: 16px; }
.av-0 { background: #C2693A; } .av-1 { background: #8C5A3C; }
.av-2 { background: #7A6A2F; } .av-3 { background: #4F8A3C; }
.av-4 { background: #A5532F; } .av-5 { background: #8A4B3A; }
.av-6 { background: #5F7A3A; } .av-7 { background: #6B5B8C; }
.brand.center { justify-content: center; }
.tc { text-align: center; }
.mt { margin-top: 18px; }
.menu form { margin: 0; }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert.err { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--good-bg); color: var(--good); }
.empty { text-align: center; padding: 48px 20px; }
.empty p { color: var(--muted); font-size: 14px; }
.form-card { max-width: 460px; margin-bottom: 16px; }
.kv { font-size: 14px; margin-bottom: 6px; }
.kv span { color: var(--muted); display: inline-block; width: 90px; }

/* ===== Forecast branding ===== */
.brand-mark { font-size: 23px; letter-spacing: 0; padding-bottom: 3px; }
.brand-mark::after { left: 8px; right: 8px; bottom: 7px; }
.brand-name { font-size: 22px; letter-spacing: .01em; line-height: 1; }
@media (max-width: 760px) { .hdr .brand-name { display: block; } }

.badge.info { color: var(--accent-ink); }
.cm-like.on, .cm-more { color: var(--accent-ink); }

.av-0 { background: #C65D3B; } .av-1 { background: #8C4A2F; }
.av-2 { background: #B07A2A; } .av-3 { background: #5F7A3A; }
.av-4 { background: #A5532F; } .av-5 { background: #7A4B3A; }
.av-6 { background: #6B7A3A; } .av-7 { background: #6B5B8C; }
