/* =========================================================
   QBPOZ — dashboard.css   (requires base.css)
   ========================================================= */

/* ---------- App grid ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--header-h) 1fr auto;
  grid-template-areas: "head" "main" "foot";
  min-height: 100vh;
  transition: grid-template-columns .35s var(--ease);
}

/* Desktop: sidebar docked inside the grid, hamburger collapses to icons */
@media (min-width: 901px) {
  .app {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-areas: "side head" "side main" "side foot";
  }
  .app.collapsed { grid-template-columns: var(--sidebar-mini) minmax(0, 1fr); }

  .app .sidebar {
    grid-area: side;
    position: sticky; top: 0;
    width: auto; height: 100vh;
    transform: none;
    box-shadow: none;
    z-index: 60;
  }
  .app .sidebar-overlay { display: none; }

  .app.collapsed .logo span,
  .app.collapsed .nav_label,
  .app.collapsed .nav a span,
  .app.collapsed .nav a .count,
  .app.collapsed .sidebar_footer .hide-mini { opacity: 0; pointer-events: none; }
  .app.collapsed .logo { padding: 0 21px; }
  .app.collapsed .nav a { padding: 11px 15px; }
}

/* ---------- Header ---------- */
.header {
  grid-area: head;
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: background-color .35s, border-color .35s;
}
.header .logo { display: none; padding: 0 6px; font-size: 24px; }
.header .logo_mark { width: 30px; height: 30px; font-size: 19px; }
.header_title { font-size: 20px; font-weight: 700; }
.header_spacer { flex: 1; }

/* ---------- Main ---------- */
.main { grid-area: main; padding: 24px; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.page-head h1 { font-family: var(--font-display); font-size: 40px; letter-spacing: 1px; font-weight: 400; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.section { margin-bottom: 30px; }
.section_head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section_head h2 { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.section_head h2::before { content: ""; width: 4px; height: 20px; border-radius: 4px; background: var(--accent); }

/* ---------- KPI stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  animation: fade-up .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms);
  transition: transform .25s var(--ease), background-color .35s, border-color .35s;
}
.stat:hover { transform: translateY(-3px); }
.stat_label { color: var(--muted); font-size: 14px; }
.stat_value { font-size: 28px; font-weight: 700; grid-column: 1; }
.stat_icon { grid-row: 1 / span 3; grid-column: 2; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat_trend { font-size: 13px; color: var(--success); }
.stat_trend.down { color: var(--danger); }

/* ---------- Top stories (touch carousel on a grid) ---------- */
.story-nav { display: flex; gap: 6px; }
.story-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 3 * 16px) / 4);
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 2px 10px;
  cursor: grab;
  user-select: none;
}
.story-track::-webkit-scrollbar { display: none; }
.story-track.dragging { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; }
.story {
  scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: fade-up .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 80ms);
  transition: transform .3s var(--ease), border-color .3s, background-color .35s;
}
.story:hover { transform: translateY(-4px); border-color: var(--accent); }
.story_media { height: 150px; position: relative; display: grid; place-items: center; color: rgba(255,255,255,.92); }
.story_media .icon { width: 54px; height: 54px; stroke-width: 1.5; transition: transform .4s var(--ease); }
.story:hover .story_media .icon { transform: scale(1.12) rotate(-4deg); }
.story_tag { position: absolute; top: 12px; left: 12px; background: rgba(0,0,0,.35); backdrop-filter: blur(4px); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; letter-spacing: .4px; }
.story_body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.story_meta { font-size: 13px; color: var(--muted); }
.story_body h4 { font-size: 18px; font-weight: 700; }
.story_body p { margin: 0; color: var(--muted); font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.story-dots { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.story-dots button { width: 8px; height: 8px; padding: 0; border-radius: 8px; border: 0; background: var(--border); transition: width .3s var(--ease), background-color .3s; }
.story-dots button.active { width: 24px; background: var(--accent); }

/* ---------- Activity cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: fade-up .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms);
  transition: background-color .35s, border-color .35s, opacity .35s, transform .35s var(--ease);
}
.card.removing { opacity: 0; transform: scale(.94); }
.card_header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 12px 12px 18px; border-bottom: 1px solid var(--border); }
.card_header h3 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card_header h3 .icon { width: 20px; height: 20px; color: var(--accent); }
.card_header .icon-btn { width: 36px; height: 36px; }
.card_body { padding: 16px 18px 18px; flex: 1; }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 8px; height: 120px; }
.bars div { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 12px; color: var(--muted); }
.bars i { display: block; width: 100%; height: var(--h); border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent)); transform-origin: bottom; animation: grow .9s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms + 300ms); }
.big-number { font-size: 26px; font-weight: 700; margin-bottom: 10px; }
.big-number small { font-size: 14px; color: var(--muted); font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .grow small { color: var(--muted); font-size: 13px; }

.progress-row { margin-bottom: 14px; }
.progress-row:last-child { margin-bottom: 0; }
.progress-row .top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.progress { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: var(--w); border-radius: 8px; background: var(--accent); transform-origin: left; animation: grow-x 1s var(--ease) both .3s; }
.progress i.ok { background: var(--success); }
.progress i.bad { background: var(--danger); }

/* ---------- Main footer ---------- */
.footer { grid-area: foot; background: var(--surface); border-top: 1px solid var(--border); padding: 34px 24px 0; transition: background-color .35s, border-color .35s; }
.footer_grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 28px; }
.footer .logo { padding: 0; margin-bottom: 10px; }
.footer p { margin: 0; color: var(--muted); font-size: 15px; }
.footer h5 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer ul a { color: var(--muted); transition: color .2s; }
.footer ul a:hover { color: var(--accent); }
.footer_bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 28px; padding: 16px 0; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }

/* ---------- Search popup ---------- */
.search-box { position: sticky; top: -18px; margin: -18px -20px 14px; padding: 18px 20px 12px; background: var(--surface); z-index: 1; }
.search-box .field { margin: 0; position: relative; }
.search-box .icon { position: absolute; left: 14px; top: 11px; color: var(--muted); }
.search-box input { padding-left: 44px; height: 46px; }
.result-count { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.results { list-style: none; margin: 0; padding: 0; }
.results li a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; transition: background-color .15s; animation: fade-up .3s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms); }
.results li a:hover { background: var(--surface-2); }
.results .type { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.results .type .icon { width: 19px; height: 19px; }
.results b { display: block; font-weight: 700; }
.results small { color: var(--muted); }
.results mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }

/* ---------- Notification popup ---------- */
.notif { display: flex; gap: 12px; padding: 12px; border-radius: 12px; position: relative; transition: background-color .2s; animation: fade-up .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.notif + .notif { margin-top: 4px; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--accent-soft); }
.notif.unread::after { content: ""; position: absolute; top: 16px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.notif_text { flex: 1; min-width: 0; padding-right: 14px; }
.notif_text p { margin: 0; font-size: 15px; }
.notif_text p b { font-weight: 700; }
.notif_time { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.notif_time .icon { width: 14px; height: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .story-track { grid-auto-columns: calc((100% - 2 * 16px) / 3); }
}
@media (max-width: 900px) {
  .header .logo { display: flex; }
  .header_title { display: none; }
  .story-track { grid-auto-columns: calc((100% - 16px) / 2); }
  .footer_grid { grid-template-columns: 1fr 1fr; }
  .footer_grid > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .main { padding: 16px; }
  .header { padding: 0 10px; gap: 2px; }
  .header .btn-login span { display: none; }
  .header .btn-login { padding: 0 11px; margin-left: 2px !important; }
  .header .logo { font-size: 22px; padding: 0 2px; }
  .header .icon-btn { width: 38px; }
  .page-head h1 { font-size: 32px; }
  .story-track { grid-auto-columns: 84%; }
  .story-nav { display: none; }
  .footer { padding: 26px 16px 0; }
  .footer_grid { grid-template-columns: 1fr; gap: 20px; }
}
