/* ===========================================================================
   READERP — rapor sihirbazı
   ---------------------------------------------------------------------------
   A drag-and-drop report builder that has to feel like a toy and behave like
   a tool. Three rules shaped it:

     It must work with a finger. HTML5 drag-and-drop does not fire on touch,
     so dragging is built on pointer events and tapping does the same job.
     A demo that dies on a phone is a demo half the visitors never see.

     Dropping something has to feel like it landed. Snap, lift, a shadow that
     follows, a settle at the end. The satisfaction is the argument: this is
     what building a report will feel like.

     The panel underneath is real. Every block names the certified query that
     feeds it, so what the visitor assembles is a real report definition and
     not a picture of one.
   =========================================================================== */

.kur {
  display: grid; gap: 20px;
  grid-template-columns: 290px minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 900px) { .kur { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- palette */
.pal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; position: sticky; top: 82px;
}
@media (max-width: 900px) { .pal { position: static; } }
.pal h3 { font-size: 16px; margin-bottom: 4px; }
.pal .hint { font-size: 13px; color: var(--ink-3); margin: 0 0 14px; }

.pal-g { margin-bottom: 15px; }
.pal-g > span {
  display: block; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 7px;
}

.blk {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; margin-bottom: 6px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--paper);
  font-family: var(--sans); font-size: 14px; font-weight: 550; color: var(--ink-1);
  cursor: grab; text-align: left;
  touch-action: none;                     /* pointer drag owns the gesture */
  transition: border-color .13s ease, background .13s ease, transform .13s ease;
}
.blk:hover { border-color: var(--amber); background: var(--amber-bg); }
.blk:active { cursor: grabbing; }
.blk .dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.blk code {
  margin-left: auto; font-family: var(--mono); font-size: 11px;
  color: var(--ink-3); background: var(--paper-2);
  padding: 2px 6px; border-radius: 4px;
}
.blk.used { opacity: .42; pointer-events: none; }
.blk.used code::after { content: " ✓"; color: var(--ok); }

/* the block that follows the finger */
.ghost {
  position: fixed; z-index: 200; pointer-events: none;
  box-shadow: var(--sh-2); transform: rotate(-1.5deg) scale(1.03);
  border-color: var(--amber); background: var(--surface);
  width: 250px; opacity: .96;
}

/* ----------------------------------------------------------------- canvas */
.cnv {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; min-height: 420px;
  display: flex; flex-direction: column;
}
.cnv-h {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--paper-2);
}
.cnv-h b { font-family: var(--disp); font-size: 15.5px; color: var(--ink); }
.cnv-h .meta { margin-left: auto; display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-3); }
.cnv-h .meta span b { font-family: var(--mono); font-size: 13px; color: var(--amber-2); }

.drop { flex: 1; padding: 18px; display: grid; gap: 14px; align-content: start; }
.drop.over { background: var(--amber-bg); }

.empty-hint {
  border: 2px dashed var(--line-2); border-radius: var(--r);
  padding: 44px 24px; text-align: center; color: var(--ink-3);
}
.empty-hint b { display: block; font-family: var(--disp); font-size: 18px;
                color: var(--ink-2); margin-bottom: 6px; }
.drop.over .empty-hint { border-color: var(--amber); color: var(--amber-2); }

/* --------------------------------------------------------------- sections */
.sec {
  border: 1px solid var(--line); border-radius: 11px; background: var(--paper);
  overflow: hidden; animation: land .34s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes land {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.sec.dragging { opacity: .35; }
.sec-h {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.sec-h .grip {
  cursor: grab; color: var(--ink-3); font-size: 15px; line-height: 1;
  padding: 2px 4px; touch-action: none;
}
.sec-h .dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.sec-h b { font-size: 14.5px; font-weight: 650; color: var(--ink); }
.sec-h code {
  font-family: var(--mono); font-size: 11px; color: var(--amber-2);
  background: var(--amber-bg); padding: 2px 7px; border-radius: 4px;
}
.sec-h .x {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  color: var(--ink-3); font-size: 17px; line-height: 1; padding: 3px 6px; border-radius: 6px;
}
.sec-h .x:hover { color: var(--bad); background: rgba(193,74,63,.1); }
.sec-b { padding: 14px; }

/* --------------------------------------------------------- mini previews */
.mv { display: block; width: 100%; height: auto; }
.mv .g { stroke: var(--line); stroke-width: 1; }
.mv text { font-family: var(--mono); font-size: 9px; fill: var(--ink-3); }
.mv rect.b { animation: pop .5s cubic-bezier(.2,1.2,.4,1) both; transform-origin: bottom; }
@keyframes pop { from { transform: scaleY(0); } to { transform: scaleY(1); } }

table.mv-t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mv-t th, table.mv-t td { text-align: left; padding: 6px 5px; border-bottom: 1px solid var(--line); }
table.mv-t th { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
table.mv-t td { color: var(--ink-2); }
table.mv-t td:first-child { color: var(--ink); font-weight: 600; }
table.mv-t .n { text-align: right; font-family: var(--mono); }
table.mv-t tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------------ suggestion */
.sug {
  display: flex; align-items: flex-start; gap: 12px;
  border: 1px dashed var(--amber); border-radius: 11px;
  background: var(--amber-bg); padding: 13px 15px;
  animation: land .3s cubic-bezier(.2,1.3,.4,1) both;
}
.sug .ic { font-size: 17px; line-height: 1.2; }
.sug p { margin: 0; font-size: 14px; color: var(--ink-1); max-width: none; }
.sug p b { color: var(--ink); }
.sug .add {
  margin-top: 9px; font-family: var(--sans); font-size: 13.5px; font-weight: 650;
  border: 1px solid var(--amber-2); background: var(--amber); color: #2a1c05;
  padding: 6px 13px; border-radius: 8px; cursor: pointer;
}
.sug .add:hover { background: #f0b258; }
.sug .no {
  margin: 9px 0 0 8px; border: 0; background: none; cursor: pointer;
  font-size: 13.5px; color: var(--ink-3); text-decoration: underline;
}

/* -------------------------------------------------------------- schedule */
.sched {
  border-top: 1px solid var(--line); background: var(--paper-2);
  padding: 15px 18px; display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center;
}
.sched label { font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 9px; }
.sched select {
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 11px;
  background: var(--surface);
}
.sched .out { margin-left: auto; font-size: 13.5px; color: var(--ink-2); }
.sched .out b { color: var(--ink); }

/* ---------------------------------------------------------------- result */
.done {
  border: 1px solid var(--amber); border-radius: var(--r);
  background: var(--amber-bg); padding: 20px 22px; margin-top: 18px;
  animation: land .4s cubic-bezier(.2,1.3,.4,1) both;
}
.done h3 { margin-bottom: 8px; }
.done p { font-size: 15px; color: var(--ink-2); margin: 0 0 14px; }
.done .qs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.done .qs code {
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--amber-2);
  background: var(--surface); border: 1px solid var(--amber-3);
  padding: 4px 9px; border-radius: 6px;
}

/* ======================================================= preview internals ==
   The blocks show what the panel shows: a KPI strip, a chart, a table with
   sparklines, a progress pipeline. Same vocabulary as the product, at a
   quarter of the size. */

.mv-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
          gap: 8px; margin-bottom: 12px; }
.mv-kpi > div { background: var(--surface); border: 1px solid var(--line);
                border-radius: 8px; padding: 8px 10px; }
.mv-kpi span { display: block; font-size: 10.5px; color: var(--ink-3); }
.mv-kpi b { font-family: var(--mono); font-size: 14.5px; color: var(--ink); }
.mv-kpi em { font-style: normal; display: block; font-size: 10.5px;
             font-weight: 600; color: var(--ink-3); margin-top: 1px; }
.mv-kpi em.up { color: var(--ok); }
.mv-kpi em.down { color: var(--bad); }

.mv-stack { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 2px; }
.mv-stack i { display: block; transform-origin: left; transform: scaleX(0);
              animation: growx .7s cubic-bezier(.22,1,.36,1) forwards; }
@keyframes growx { to { transform: scaleX(1); } }
.mv-key { list-style: none; padding: 0; margin: 11px 0 0;
          display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px;
          font-size: 11.5px; color: var(--ink-2); }
.mv-key li { display: flex; align-items: center; gap: 7px; }
.mv-key i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.mv-key b { margin-left: auto; font-family: var(--mono); color: var(--ink); }

.mv-rows { display: grid; gap: 8px; }
.mv-row { display: grid; grid-template-columns: 92px 1fr 62px; gap: 10px;
          align-items: center; font-size: 12.5px; }
.mv-row > span:first-child { color: var(--ink-2); }
.mv-row .tr { height: 10px; background: var(--paper-2); border-radius: 5px; overflow: hidden; }
.mv-row .tr i { display: block; height: 100%; border-radius: 5px;
                transform-origin: left; transform: scaleX(0);
                animation: growx .7s cubic-bezier(.22,1,.36,1) forwards; }
.mv-row b { text-align: right; font-family: var(--mono); color: var(--ink); }

.mv-t .up { color: var(--ok); }
.mv-t .down { color: var(--bad); }
.mv-t svg.sp { display: block; width: 56px; height: 16px; }
.tg { font-size: 10.5px; font-weight: 650; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.tg.bad { background: rgba(193,74,63,.13); color: var(--bad); }
.tg.warn { background: rgba(184,121,27,.15); color: var(--warn); }
.tg.ok { background: rgba(26,138,95,.13); color: var(--ok); }

/* target pipeline: quarters stacked toward the goal line */
.mv-pipe { position: relative; display: flex; height: 26px; gap: 2px;
           background: var(--paper-2); border-radius: 7px; overflow: visible; }
.mv-pipe i { display: block; height: 100%; transform-origin: left; transform: scaleX(0);
             animation: growx .8s cubic-bezier(.22,1,.36,1) forwards; }
.mv-pipe i:first-child { border-radius: 7px 0 0 7px; }
.mv-pipe .goal { position: absolute; top: -4px; bottom: -4px; width: 2px;
                 background: var(--ink); border-radius: 1px; }
.mv-pipe .goal em { position: absolute; top: -15px; left: 50%; transform: translateX(-50%);
                    font-style: normal; font-family: var(--mono); font-size: 9.5px;
                    color: var(--ink); white-space: nowrap; }
.mv-pipe-l { display: flex; justify-content: space-between; margin-top: 9px;
             font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.mv-pipe-l span:first-child { color: var(--ink); font-weight: 600; }

.mv-q { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mv-q > div { background: var(--surface); border: 1px solid var(--line);
              border-radius: 8px; padding: 9px; display: grid; gap: 3px; }
.mv-q span { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.mv-q b { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.stars { font-style: normal; display: flex; gap: 1px; }
.stars em { font-style: normal; font-size: 10px; color: var(--line-2); }
.stars em.on { color: var(--amber); }

.mv-find { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mv-find > div { display: flex; align-items: baseline; gap: 9px;
                 background: var(--paper-2); border-radius: 8px; padding: 9px 11px; }
.mv-find b { font-family: var(--mono); font-size: 17px; }
.mv-find span { font-size: 11.5px; color: var(--ink-2); }
.mv-find .bad b { color: var(--bad); }
.mv-find .warn b { color: var(--warn); }
.mv-find .info b { color: var(--d5); }
.mv-find .ok b { color: var(--ok); }

.mv-note { margin: 12px 0 0; padding-top: 11px; border-top: 1px solid var(--line);
           font-size: 12px; line-height: 1.5; color: var(--ink-3); }

.mv .dr { stroke-dasharray: 600; stroke-dashoffset: 600;
          animation: dash 1.1s cubic-bezier(.4,0,.2,1) forwards; }
@keyframes dash { to { stroke-dashoffset: 0; } }

/* a block being carried, and the hole it leaves */
.sec.lifting { opacity: .5; transform: scale(.985); box-shadow: var(--sh-2); }
.sec-gap { border: 2px dashed var(--amber); border-radius: 11px;
           background: var(--amber-bg); }
