/* ============================================================
   panels.css — lineage drawer, saved-query modal, toasts,
   responsive rules
   ============================================================ */

/* ---------- overlay + drawer ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(29, 27, 22, .32);
  backdrop-filter: blur(2px);
  z-index: 80;
  opacity: 0;
  transition: opacity .22s ease;
}
.overlay.open { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 452px;
  max-width: 94vw;
  background: var(--surface);
  z-index: 90;
  box-shadow: -18px 0 50px rgba(29, 27, 22, .18);
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.32, .72, .24, 1);
}
.drawer.open { transform: translateX(0); }
.drawer-inner {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer-head {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 22px 15px;
  z-index: 2;
}
.drawer-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drawer-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.drawer-id {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  margin-top: 3px;
}
.drawer-close {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: all .14s;
}
.drawer-close:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--ink); }

.drawer-section {
  padding: 17px 22px;
  border-bottom: 1px solid var(--border);
}
.drawer-section:last-child { border-bottom: 0; }
.drawer-h {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drawer-desc {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0;
}

.drawer-stat-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.drawer-value {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.drawer-value.masked { color: var(--faint); letter-spacing: .14em; }

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.meta-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.meta-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.meta-value { font-size: 12.5px; font-weight: 600; }
.meta-value .sub { display: block; font-weight: 400; font-size: 11px; color: var(--muted); margin-top: 1px; }

.cov-meter {
  height: 5px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-top: 7px;
  overflow: hidden;
}
.cov-meter i { display: block; height: 100%; background: var(--good); }
.cov-meter i.low { background: #C39A2E; }

/* kepler source */

.table-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 7px;
  background: var(--surface-2);
}
.table-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.table-meta {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.field-chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2.5px 8px;
  margin: 0 5px 5px 0;
  color: var(--ink-2);
}

.query-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #BCD2C4;
  background: var(--accent-soft);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--sans);
  text-align: left;
  transition: all .14s;
}
.query-link:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(37, 107, 78, .12); }
.query-link .q-name {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-ink);
}
.query-link .q-meta { font-size: 11px; color: var(--accent-ink); opacity: .75; margin-top: 2px; }
.query-link .q-open {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
  white-space: nowrap;
}

.restricted-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 13px;
  border: 1px solid #E4D5CF;
  background: #F9F2F0;
  border-radius: 10px;
  font-size: 12.5px;
  color: #8A4A3A;
  line-height: 1.5;
}
.warn-mark {
  width: 17px; height: 17px;
  border-radius: 50%;
  background: #B0492E;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 1px;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: all .14s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn:hover { border-color: var(--muted); box-shadow: 0 1px 4px rgba(29, 27, 22, .1); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* slack discussion */

.channel-card {
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}
.channel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.channel-name {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
}
.channel-name::before {
  content: '#';
  color: var(--faint);
  font-weight: 500;
}
.channel-members { font-size: 11px; color: var(--muted); }
.channel-topic {
  padding: 8px 13px;
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-style: italic;
}
.msg {
  display: flex;
  gap: 10px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
}
.msg:last-child { border-bottom: 0; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  letter-spacing: .02em;
}
.msg-body { min-width: 0; }
.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 2px;
}
.msg-user { font-size: 12px; font-weight: 700; }
.msg-role { font-size: 10.5px; color: var(--muted); }
.msg-ts { font-size: 10.5px; color: var(--faint); margin-left: auto; font-family: var(--mono); }
.msg-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }

/* annotations */

.ann-list { margin-bottom: 11px; }
.ann-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.ann-item:last-child { border-bottom: 0; }
.ann-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; flex: 1; }
.ann-ts { font-size: 10.5px; color: var(--faint); font-family: var(--mono); white-space: nowrap; }
.ann-del {
  appearance: none;
  border: 0;
  background: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  align-self: flex-start;
}
.ann-del:hover { color: var(--bad); }
.ann-form { display: flex; gap: 8px; }
.ann-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 38px;
  max-height: 120px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 11px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  transition: border-color .14s;
}
.ann-form textarea:focus { border-color: var(--accent); background: var(--surface); }
.ann-empty { font-size: 12px; color: var(--muted); margin-bottom: 11px; }

/* ---------- modal (saved query) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 27, 22, .4);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .16s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(29, 27, 22, .3);
  width: 620px;
  max-width: 100%;
  max-height: 84vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s cubic-bezier(.32, .72, .24, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  padding: 17px 20px 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
}
.modal-title .qid {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid #BCD2C4;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.modal-meta {
  display: flex;
  gap: 16px;
  padding: 10px 20px;
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.modal-meta b { color: var(--ink-2); font-weight: 600; }
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}
.sql-block {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  background: #23211C;
  color: #E8E4DA;
  border-radius: 11px;
  padding: 16px 18px;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.modal-foot {
  padding: 13px 20px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #F5F3EE;
  font-size: 12.5px;
  font-weight: 500;
  padding: 10px 17px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(29, 27, 22, .3);
  animation: toastIn .22s cubic-bezier(.32, .72, .24, 1);
  max-width: 80vw;
}
.toast.leaving { animation: toastOut .25s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .row-2 { grid-template-columns: 1fr; }
  .target-card { min-height: 0; }
}
@media (max-width: 680px) {
  .page { padding: 24px 16px 18px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .head-controls { width: 100%; }
  .head-title h1 { font-size: 23px; }
  .meta-grid { grid-template-columns: 1fr; }
  .health th:nth-child(4), .health td:nth-child(4),
  .health th:nth-child(5), .health td:nth-child(5) { display: none; }
  .trend-cell { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
