/* Instagram tab (js/instagram.js): both accounts' history beside the CRM's
   cash. Cash keeps the Revenue tab's green (money reads the same
   everywhere); Instagram's own numbers are rose. The two charts share
   their columns so a week reads straight down. */

.ig-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.ig-title { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.ig-title h2 { font-size: 20px; font-weight: 700; letter-spacing: -.3px; color: var(--ink); }
.ig-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ig-chip {
  display: inline-block; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none;
}
.ig-chip:hover { color: var(--ink); border-color: #c8d2de; }
.ig-chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.ig-src { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.ig-status { display: inline-flex; align-items: center; gap: 8px; line-height: 1.35; }
.ig-status b { color: var(--ink); font-weight: 650; }
.ig-status.is-busy { background: var(--blue-bg); color: var(--blue); border-radius: 999px; padding: 5px 12px 5px 10px; }
.ig-status.is-busy b { color: var(--blue); }
.ig-status.is-warn b { color: var(--amber); }
.ig-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.ig-spin {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: igSpin .8s linear infinite;
}
@keyframes igSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ig-spin { animation: none; border-right-color: currentColor; opacity: .6; } }
.ig-sync:disabled { opacity: .6; cursor: default; }
.ig-note {
  background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--amber);
  border-radius: 8px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px;
}

.ig-blank { padding: 26px 24px; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.ig-blank h3 { font-size: 15px; color: var(--ink); margin-bottom: 6px; }
.ig-blank code, .ig-about code, .ig-fine code { background: var(--grey-bg); border-radius: 4px; padding: 1px 5px; font-size: 11.5px; }

/* the headline tiles */
.ig-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.ig-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px 16px; min-width: 0;
}
.ig-tile-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.ig-tile-value { font-size: 24px; font-weight: 800; color: var(--ink); letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ig-tile-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; min-height: 16px; }
.ig-delta { font-weight: 700; color: var(--muted); }
.ig-delta.up { color: var(--green); }
.ig-delta.down { color: var(--red); }
.ig-fine { font-size: 11.5px; color: var(--faint); line-height: 1.5; margin-top: 10px; }
.ig-tiles + .ig-fine { margin: 0 0 14px; }
.ig-tiles + .card, .ig-tiles + .ig-fine + .card { margin-top: 14px; }

/* the two charts on shared columns */
.ig-chart { padding: 18px 22px 16px; margin-bottom: 14px; }
.ig-chart-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 14px; }
.ig-chart-head h3 { font-size: 15px; font-weight: 700; color: var(--ink); }
.ig-chart-head-2 { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.ig-chart-tools { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.ig .seg-opt { text-decoration: none; white-space: nowrap; }
/* a switch wider than its card scrolls inside it rather than widening the page */
.ig-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.ig-seg::-webkit-scrollbar { display: none; }
.ig-key { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.ig-sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ig-sw-new { background: var(--green); }
.ig-sw-inst { background: var(--green-line); }

.ig-cols, .ig-labels { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; }
.ig-cols { height: 150px; align-items: end; }
.ig-col { height: 100%; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.ig-col-val { font-size: 10.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ig-col-bar {
  width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; display: flex; flex-direction: column; overflow: hidden;
}
.ig-bar-ig { background: var(--rose); }
.ig-bar-cash { background: var(--green); }
.ig-bar-inst { flex: none; width: 100%; background: var(--green-line); border-bottom: 2px solid var(--surface); }
.ig-col.partial .ig-col-bar { opacity: .5; }
.ig-col.partial .ig-col-val { color: var(--faint); }
.ig-col.empty { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line-soft) 5px 6px); border-radius: 4px; }
.ig-labels { margin-top: 6px; }
.ig-labels span { font-size: 10.5px; color: var(--faint); text-align: center; white-space: nowrap; overflow: hidden; }
.ig-labels span.partial { font-style: italic; }

.ig-link { margin-bottom: 14px; }
.ig-link .card-body { padding: 16px 22px; }
.ig-link h3 { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.ig-link ul { margin: 0 0 0 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.ig-link b { color: var(--ink); }

.ig-posts { margin-bottom: 14px; padding-top: 16px; }
.ig-posts > .ig-chart-head { padding: 0 20px; }
.ig-table th.num, .ig-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ig-table th.sorted { color: var(--ink); }
.ig-table td.nowrap { white-space: nowrap; color: var(--muted); }
.ig-table td.ig-cap { min-width: 240px; max-width: 420px; }
.ig-table td.ig-cap a { color: var(--ink); text-decoration: none; }
.ig-table td.ig-cap a:hover { text-decoration: underline; }
.ig-more { padding: 10px 16px 0; }
.ig-posts > .ig-fine { padding: 0 20px 14px; }

.ig-about { font-size: 12px; color: var(--faint); line-height: 1.6; margin: 4px 2px 20px; }

@media (max-width: 900px) {
  .ig-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .ig-chart { padding: 14px 12px 12px; }
  .ig-cols, .ig-labels { gap: 2px; }
  .ig-cols { height: 110px; }
  .ig-col-val { display: none; }
  /* every third week named, the names free to run over the hidden ones */
  .ig-labels span { overflow: visible; }
  .ig-labels span:not(:nth-child(3n+1)) { visibility: hidden; }
  .ig-src { width: 100%; justify-content: space-between; }
}
