/* ============================================================
 * Polaris Social Manager — Design System & Styles
 * Brand: 深蓝 #002A50 + 青绿 #34CCB5  (武汉天极 POLARIS)
 * ============================================================ */

:root {
  --navy: #002A50;
  --navy-2: #003a6e;
  --teal: #34CCB5;
  --teal-d: #1fab97;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(0, 42, 80, 0.08);
  --shadow-lg: 0 18px 50px rgba(0, 42, 80, 0.18);
  --font: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  /* light theme (default) */
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --border: #e2e9f1;
  --text: #0f2238;
  --text-2: #5a6b80;
  --text-3: #93a2b5;
  --sidebar-bg: var(--navy);
  --sidebar-text: #c9d8ea;
  --sidebar-active: rgba(52, 204, 181, 0.16);
}

[data-theme="dark"] {
  --bg: #0c1622;
  --surface: #14202f;
  --surface-2: #1b2a3c;
  --border: #243648;
  --text: #e6eef8;
  --text-2: #9fb2c8;
  --text-3: #6c8098;
  --sidebar-bg: #081320;
  --sidebar-text: #aebfd2;
  --sidebar-active: rgba(52, 204, 181, 0.18);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

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

.sidebar {
  width: 246px; flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .logo { width: 38px; height: 38px; flex-shrink: 0; }
.brand .b-name { font-weight: 700; color: #fff; font-size: 15px; letter-spacing: .3px; }
.brand .b-sub { font-size: 11px; color: var(--teal); letter-spacing: 1px; text-transform: uppercase; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  margin-bottom: 4px; transition: background .18s, color .18s;
  position: relative;
}
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--teal);
}
.nav-badge {
  margin-left: auto; background: var(--teal); color: var(--navy);
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
}
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11px; color: var(--text-3); }

.main { flex: 1; margin-left: 246px; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Topbar ---------- */
.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 22px;
  position: sticky; top: 0; z-index: 40;
}
.hamburger { display: none; font-size: 20px; color: var(--text); width: 36px; height: 36px; border-radius: 8px; }
.hamburger:hover { background: var(--surface-2); }
.search {
  flex: 1; max-width: 440px; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 14px; color: var(--text-3);
}
.search input { border: none; background: none; outline: none; flex: 1; color: var(--text); font-size: 13px; }
.search input::placeholder { color: var(--text-3); }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  color: var(--text-2); position: relative; transition: background .18s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; background: #ff5b5b; border-radius: 50%; border: 2px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; border-radius: 30px; border: 1px solid var(--border); }
.user-chip .av { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--navy), var(--teal)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-chip .un { font-size: 12.5px; font-weight: 600; }
.user-chip .ur { font-size: 11px; color: var(--text-3); }

.content { padding: 24px; flex: 1; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head p { color: var(--text-2); margin-top: 4px; font-size: 13.5px; }

/* ---------- Cards & Grid ---------- */
.grid { display: grid; gap: 18px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-h h3 { font-size: 14px; font-weight: 700; }
.card-h .more { font-size: 12.5px; color: var(--teal-d); font-weight: 600; }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .k-top { display: flex; align-items: center; gap: 10px; }
.kpi .k-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; }
.kpi .k-label { color: var(--text-2); font-size: 12.5px; }
.kpi .k-val { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi .k-trend { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.k-up { color: var(--teal-d); }
.k-down { color: #ff6b6b; }
.kpi .spark { margin-top: 2px; }

.two-col { grid-template-columns: 1.6fr 1fr; align-items: start; }

/* ---------- Platform legend ---------- */
.legend { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-val { margin-left: auto; font-weight: 700; }

/* ---------- Account list ---------- */
.acc-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.acc-card { display: flex; flex-direction: column; gap: 12px; }
.acc-top { display: flex; align-items: center; gap: 12px; }
.acc-ava { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.acc-meta { min-width: 0; }
.acc-meta .h { font-weight: 700; font-size: 14px; }
.acc-meta .o { color: var(--text-3); font-size: 12px; }
.acc-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-2); }
.acc-row .v { font-weight: 700; color: var(--text); }
.pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.pill-ok { background: rgba(52,204,181,.16); color: var(--teal-d); }
.pill-no { background: rgba(255,107,107,.14); color: #ff6b6b; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 13px;
  background: var(--navy); color: #fff; transition: transform .12s, background .18s, box-shadow .18s;
}
.btn:hover { background: var(--navy-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-teal { background: var(--teal); color: var(--navy); }
.btn-teal:hover { background: var(--teal-d); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }

/* ---------- Inbox ---------- */
.inbox-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; height: calc(100vh - 200px); min-height: 460px; }
.inbox-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab { flex: 1; padding: 13px 8px; font-size: 13px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; }
.tab.active { color: var(--navy); border-bottom-color: var(--teal); }
[data-theme="dark"] .tab.active { color: var(--teal); }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 11px; padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--sidebar-active); }
.conv .c-av { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--navy); flex-shrink: 0; }
.conv .c-body { min-width: 0; flex: 1; }
.conv .c-name { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.conv .c-text { color: var(--text-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .c-time { font-size: 11px; color: var(--text-3); }
.conv .unread { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); margin-left: auto; }
.plat-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; color: #fff; }

.thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.thread-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.thread-head .t-name { font-weight: 700; }
.thread-head .t-sub { font-size: 12px; color: var(--text-3); }
.thread-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--surface-2); }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; }
.msg.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.msg .m-time { font-size: 10.5px; opacity: .6; margin-top: 4px; }
.reply-bar { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.reply-bar input { flex: 1; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none; font-size: 13px; }
.reply-bar input:focus { border-color: var(--teal); }

/* ---------- Publisher ---------- */
.pub-grid { grid-template-columns: 1fr 1.4fr; align-items: start; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.media-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.media-thumb { aspect-ratio: 1; display: grid; place-items: center; font-size: 30px; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: var(--teal); }
.media-item .m-name { padding: 8px 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item .m-size { padding: 0 10px 8px; font-size: 10.5px; color: var(--text-3); }

.post-row { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.post-row:last-child { border-bottom: none; }
.post-ava { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0; }
.post-main { flex: 1; min-width: 0; }
.post-main .p-cap { font-size: 13.5px; }
.post-main .p-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status-pill { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.st-scheduled { background: rgba(52,204,181,.16); color: var(--teal-d); }
.st-published { background: rgba(0,42,80,.1); color: var(--navy); }
[data-theme="dark"] .st-published { background: rgba(255,255,255,.08); color: #cfe; }
.st-draft { background: rgba(255,176,32,.16); color: #d99400; }

/* ---------- Ads / Coming soon ---------- */
.coming-soon { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 60px 20px; text-align: center; }
.coming-soon .cs-ico { width: 84px; height: 84px; border-radius: 22px; background: linear-gradient(135deg, var(--navy), var(--teal)); display: grid; place-items: center; font-size: 38px; color: #fff; box-shadow: var(--shadow-lg); }
.coming-soon h2 { font-size: 20px; }
.coming-soon p { color: var(--text-2); max-width: 460px; }
.badge-soon { background: rgba(52,204,181,.16); color: var(--teal-d); font-weight: 700; padding: 4px 14px; border-radius: 20px; font-size: 12px; }

/* ---------- Leads table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 16px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { font-weight: 700; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
.lead-name { font-weight: 700; }
.chan-tag { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); }
.st-new { background: rgba(52,204,181,.16); color: var(--teal-d); }
.st-contacted { background: rgba(0,42,80,.1); color: var(--navy); }
[data-theme="dark"] .st-contacted { background: rgba(255,255,255,.08); color: #cfe; }
.st-won { background: rgba(46,204,113,.16); color: #2ecc71; }
.st-lost { background: rgba(255,107,107,.14); color: #ff6b6b; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(8,19,32,.55); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .22s cubic-bezier(.2,.8,.3,1.2); }
@keyframes pop { from { transform: scale(.94) translateY(8px); opacity: 0 } to { transform: scale(1) translateY(0); opacity: 1 } }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
.modal-b { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); outline: none; font-size: 13.5px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); }
.field textarea { resize: vertical; min-height: 76px; }
.plat-options { display: flex; flex-wrap: wrap; gap: 8px; }
.plat-opt { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.plat-opt.sel { border-color: var(--teal); background: var(--sidebar-active); color: var(--teal-d); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transition: all .3s; z-index: 200; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .t-ico { color: var(--teal); margin-right: 8px; }

/* ---------- Chart svg ---------- */
.chart-svg { width: 100%; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-3); font-size: 9px; }
.donut-arc { transition: stroke-width .2s; }
.donut-num { fill: var(--text); font-size: 22px; font-weight: 800; }
.donut-label { fill: var(--text-3); font-size: 10px; }

/* ---------- Overlay scrim for mobile sidebar ---------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .pub-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: grid; }
  .scrim.show { display: block; }
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .inbox-list { max-height: 320px; }
  .search { max-width: none; }
  .user-chip .un, .user-chip .ur { display: none; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .media-grid { grid-template-columns: repeat(2, 1fr); }
  .page-head h1 { font-size: 19px; }
}
