/* ============================================================
   Realpem Social Suite — glass UI
   Themes: html[data-theme="dark|light"]
   Accents: html[data-accent="ocean|ember|aurora"]
   ============================================================ */

:root {
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
}

html[data-accent="ocean"]  { --accent: #4DA3FF; --accent-soft: rgba(77,163,255,.14); }
html[data-accent="ember"]  { --accent: #FF7A45; --accent-soft: rgba(255,122,69,.14); }
html[data-accent="aurora"] { --accent: #9D7BFF; --accent-soft: rgba(157,123,255,.14); }

html[data-theme="dark"] {
  --bg: #0B0F17;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%), #0B0F17;
  --panel: rgba(18, 24, 38, .72);
  --panel-solid: #121826;
  --line: rgba(255,255,255,.08);
  --text: #E8EDF6;
  --muted: #8A94A8;
  --up: #3DDC97;
  --down: #FF5C6C;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
html[data-theme="light"] {
  --bg: #F3F5FA;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%), #F3F5FA;
  --panel: rgba(255,255,255,.8);
  --panel-solid: #FFFFFF;
  --line: rgba(15,23,42,.1);
  --text: #101828;
  --muted: #5B6577;
  --up: #0F9D6C;
  --down: #D93848;
  --shadow: 0 10px 30px rgba(16,24,40,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; }
h1 { font-size: 1.55rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */
body.app { display: flex; }
.sidebar {
  width: 232px; min-height: 100vh; position: sticky; top: 0;
  background: var(--panel); backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: conic-gradient(from 210deg, var(--accent), #7ef0c9, var(--accent));
  animation: spinHue 9s linear infinite;
}
@keyframes spinHue { to { filter: hue-rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .brand-mark { animation: none; } }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
.brand-name b { color: var(--accent); font-weight: 700; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: .93rem;
}
.side-link:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.side-link.active { color: var(--text); background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.side-ico { width: 18px; text-align: center; opacity: .9; }

.side-foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.accent-dots { display: flex; gap: 6px; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.dot-ocean { background: #4DA3FF; } .dot-ember { background: #FF7A45; } .dot-aurora { background: #9D7BFF; }
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.logout { margin-left: auto; padding: 6px 8px; }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: var(--panel); backdrop-filter: blur(18px);
  position: sticky; top: 0; z-index: 30;
}
.menu-btn { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 10px; font-size: 1rem; cursor: pointer; }
.topbar-title { font-family: var(--font-display); font-weight: 600; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
.uname { color: var(--muted); font-size: .9rem; }

.container { padding: 26px; max-width: 1180px; width: 100%; margin: 0 auto; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--panel); backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.mt { margin-top: 16px; }

.stat-label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; margin: 2px 0; }
.delta { font-size: .8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.delta-up { color: var(--up); background: rgba(61,220,151,.12); }
.delta-down { color: var(--down); background: rgba(255,92,108,.12); }
.delta-flat { color: var(--muted); background: var(--accent-soft); }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

/* ---------- Buttons, forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel-solid); color: var(--text);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font: 500 .9rem var(--font-body);
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--down); border-color: rgba(255,92,108,.4); }
.btn-sm { padding: 4px 12px; font-size: .82rem; }

label { display: block; margin-bottom: 12px; font-weight: 500; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=date], input[type=datetime-local], input[type=color],
select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 12px;
  background: var(--panel-solid); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: 400 .92rem var(--font-body);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .dot:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { min-height: 110px; resize: vertical; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: .9rem; }
.alert-error { background: rgba(255,92,108,.12); color: var(--down); border: 1px solid rgba(255,92,108,.3); }
.alert-success { background: rgba(61,220,151,.12); color: var(--up); border: 1px solid rgba(61,220,151,.3); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--accent-soft); }

.badge { padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-draft { background: var(--accent-soft); color: var(--muted); }
.badge-scheduled { background: rgba(77,163,255,.15); color: var(--accent); }
.badge-published { background: rgba(61,220,151,.14); color: var(--up); }
.badge-failed { background: rgba(255,92,108,.14); color: var(--down); }

/* ---------- Channels grid ---------- */
.channel-card { display: flex; align-items: center; gap: 14px; }
.channel-ico {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-display); color: #fff; font-size: .9rem;
}
.channel-body { flex: 1; min-width: 0; }
.channel-name { font-weight: 600; }
.channel-hint { color: var(--muted); font-size: .82rem; }
.channel-handle { color: var(--accent); font-size: .84rem; }
.group-title { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 22px 0 10px; }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { width: 100%; height: 230px; display: block; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: .8rem; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------- Filters bar ---------- */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters label { margin: 0; }
.filters input, .filters select { width: auto; }

/* ---------- Planner ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { color: var(--muted); font-size: .75rem; text-transform: uppercase; text-align: center; padding: 4px; }
.cal-day { min-height: 92px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: var(--panel-solid); font-size: .78rem; }
.cal-day.today { border-color: var(--accent); }
.cal-day.dim { opacity: .38; }
.cal-num { color: var(--muted); font-size: .72rem; }
.cal-post { display: block; margin-top: 4px; padding: 3px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--text); font-size: .72rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- Post list ---------- */
.post-thumb { width: 44px; height: 56px; border-radius: 8px; background: linear-gradient(160deg, var(--accent-soft), var(--panel-solid)); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: .68rem; }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }
.pagination a, .pagination span.pg { padding: 5px 11px; border: 1px solid var(--line); border-radius: 8px; }
.pagination span.pg.cur { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Auth gate ---------- */
body.gate { display: block; }
.gate-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); backdrop-filter: blur(18px); border: 1px solid var(--line); border-radius: 20px; padding: 30px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 0; }

/* ---------- Report print ---------- */
@media print {
  .sidebar, .topbar, .footer, .no-print { display: none !important; }
  body, .shell, .container { background: #fff !important; color: #000; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; background: #fff; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 50; left: -240px; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .menu-btn { display: inline-flex; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding: 16px; }
  .cal-day { min-height: 64px; }
  .uname { display: none; }
}
