/* layout.css — shell, header, stat cards, panel, tabs */

.shell {
  width: min(1280px, calc(100% - 32px));
  padding: 18px 0 40px;
  margin: 0 auto;
  animation: fadeIn var(--tr-slow) both;
}

/* ── Header ────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 10px 16px;
  border-radius: var(--rad2);
  background: var(--bg-glass);
  border: 1px solid var(--bg3);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 10px;
  z-index: 60;
  animation: fadeUp var(--tr-slow) both;
}

.brand { display: flex; align-items: center; gap: 10px; }

/* Animated logo mark: rotating ring + steady core */
.brand-mark {
  width: 30px; height: 30px;
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
}
.brand-mark::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: conic-gradient(from 0deg, var(--acc), var(--cyan), var(--acc2), var(--acc));
  animation: spin 7s linear infinite;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 7px;
  background: var(--bg2);
}
.brand-mark span {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 700;
  color: var(--acc3);
}

header h1 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -.4px;
  white-space: nowrap;
}
header h1 b { color: var(--fg); font-weight: 700; }
header h1 span {
  background: linear-gradient(92deg, var(--acc2), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 600;
}
header h1 i {
  font-style: normal;
  font-size: .62rem;
  font-family: var(--mono);
  color: var(--fg3);
  border: 1px solid var(--bg4);
  padding: 1px 5px;
  border-radius: 5px;
  margin-left: 6px;
  vertical-align: 2px;
}

.hdr-r { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ── Scheduler pill ────────────────────────────────────────── */

.sched-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--bg3);
  border: 1px solid var(--bg4);
  font-size: .71rem;
  color: var(--fg2);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--tr), color var(--tr), background var(--tr);
  white-space: nowrap;
}
.sched-pill:hover { border-color: var(--acc); color: var(--fg); }
.sched-pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--fg3);
  flex: none;
}
.sched-pill.on { color: var(--fg); border-color: rgba(16, 185, 129, .4); }
.sched-pill.on .dot { background: var(--g); animation: pulseRing 2s ease-out infinite; }

/* ── Stat cards ────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  border-radius: var(--rad2);
  background: var(--bg2);
  border: 1px solid var(--bg3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .25);
  transition: border-color var(--tr), transform var(--tr), box-shadow var(--tr);
  animation: fadeUp var(--tr-slow) both;
}
.stat:nth-child(1) { animation-delay: .02s }
.stat:nth-child(2) { animation-delay: .06s }
.stat:nth-child(3) { animation-delay: .10s }
.stat:nth-child(4) { animation-delay: .14s }
.stat:nth-child(5) { animation-delay: .18s }

.stat:hover {
  border-color: var(--acc);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35), 0 0 15px rgba(99, 102, 241, .15);
}

/* Top hairline that lights up on hover */
.stat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--acc), transparent);
  opacity: 0;
  transition: opacity var(--tr);
}
.stat:hover::after { opacity: .85; }

.stat .l {
  font-size: .63rem;
  color: var(--fg3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 5px;
}
.stat .v {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1.05;
  color: var(--fg);
}
.stat .v.run  { color: var(--y); }
.stat .v.ok   { color: var(--g); }
.stat .v.fail { color: var(--r); }
/* Applied briefly by JS when the number changes */
.stat .v.bump { animation: countUp 320ms ease-out; }

/* ── Panel + tabs ──────────────────────────────────────────── */

.main-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }

.panel {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--rad3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .28);
  overflow: hidden;
  animation: fadeUp var(--tr-slow) .1s both;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  background: #0f1320;
  border-bottom: 1px solid var(--bg3);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  padding: 10px 16px 12px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--fg3);
  cursor: pointer;
  white-space: nowrap;
  border-radius: var(--rad) var(--rad) 0 0;
  transition: color var(--tr), background var(--tr);
}
.tab:hover { color: var(--fg); background: rgba(255, 255, 255, .04); }
.tab.active { color: var(--fg); font-weight: 600; }

/* Sliding underline */
.tab::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(90deg, var(--acc), var(--cyan));
  transform: scaleX(0);
  transform-origin: center;
  transition: transform var(--tr);
}
.tab.active::after { transform: scaleX(1); }

.tab .cnt {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--bg3);
  font-family: var(--mono);
  font-size: .62rem;
  color: var(--fg3);
  vertical-align: 1px;
}
.tab.active .cnt { background: rgba(99, 102, 241, .2); color: var(--acc3); }

.tab-body { display: none; }
.tab-body.active { display: block; animation: fadeIn var(--tr) both; }

/* ── Toolbars ──────────────────────────────────────────────── */

.tab-tools {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-bottom: 1px solid var(--bg3);
  font-size: .75rem;
}
.tab-tools .hint {
  color: var(--fg3);
  font-size: .7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab-tools .spacer { flex: 1; }

/* ── Bulk action dropdown button ──────────────────────────────
   Lives inside tab-tools next to the Fetch button. The <details>
   element gives us open/close state for free, including
   click-outside-to-close via the delegated handler in main.js. */

.bulk-dd {
  position: relative;
  display: none;               /* only shown when rows are selected */
  animation: fadeIn var(--tr) both;
}
.bulk-dd.show { display: inline-flex; }

.bulk-dd > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  border-radius: var(--rad);
  background: linear-gradient(135deg, #3730a3, #312e81);
  color: #fff;
  border: 1px solid #4f46e5;
  box-shadow: 0 2px 10px rgba(49, 46, 129, .28);
  cursor: pointer;
  user-select: none;
  transition: background var(--tr), box-shadow var(--tr);
  white-space: nowrap;
}
.bulk-dd > summary::-webkit-details-marker { display: none; }
.bulk-dd > summary:hover { background: linear-gradient(135deg, #4338ca, #3730a3); }
.bulk-dd > summary .chev {
  font-size: .58rem;
  transition: transform var(--tr);
}
.bulk-dd[open] > summary .chev { transform: rotate(180deg); }
.bulk-dd > summary .n {
  font-family: var(--mono);
  background: rgba(255, 255, 255, .16);
  border-radius: 99px;
  padding: 0 6px;
  font-size: .64rem;
}

.bulk-dd .menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  min-width: 200px;
  padding: 5px;
  background: var(--bg2);
  border: 1px solid var(--bg4);
  border-radius: var(--rad);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .5);
  animation: popIn 150ms both;
}
.bulk-dd .menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  font-size: .76rem;
  border: none;
  background: transparent;
  color: var(--fg2);
  border-radius: 6px;
}
.bulk-dd .menu button:hover { background: var(--bg3); color: var(--fg); }
.bulk-dd .menu button.danger { color: var(--r); }
.bulk-dd .menu button.danger:hover { background: rgba(244, 63, 94, .1); }
.bulk-dd .menu .sep { height: 1px; margin: 4px 6px; background: var(--bg3); }

/* ── Responsive container ─────────────────────────────────── */

@media (max-width: 900px) {
  .shell {
    width: min(100% - 20px, 760px);
    padding-top: 10px;
  }

  header {
    position: static;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .brand { flex: 1; }
  .sched-pill { order: 2; }
  .hdr-r {
    order: 3;
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .hdr-r button { min-width: 0; padding-inline: 7px; }

  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel { border-radius: var(--rad2); }

  /* Tables remain readable and scroll inside their own container rather than
     forcing the whole page wider than the viewport. */
  .tbl-wrap {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
  .tbl-wrap table { min-width: 780px; }
}

@media (max-width: 600px) {
  .shell { width: calc(100% - 12px); padding-bottom: 24px; }

  header { gap: 8px; margin-bottom: 10px; }
  .brand-mark { width: 27px; height: 27px; }
  header h1 { font-size: 1rem; }
  .sched-pill { padding: 4px 9px; font-size: .66rem; }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 10px;
  }
  .stat { padding: 10px 11px; }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat .v { font-size: 1.3rem; }

  .tabs { padding-inline: 5px; }
  .tab { padding: 9px 11px 10px; font-size: .76rem; }
  .tab .cnt { display: none; }

  .tab-tools {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 8px 9px;
  }
  .tab-tools .hint { flex: 1 1 100%; }
  .tab-tools .spacer { display: none; }
  .tab-tools > :not(.hint) { margin-left: auto; }
  .tab-tools > :not(.hint):not(:last-child) { margin-left: 0; margin-right: 8px; }

  .bulk-dd .menu {
    right: auto;
    left: 0;
    min-width: 180px;
  }
}
