/* ============================================================
   forecast.css — Resource Forecasting Dashboard
   ============================================================ */

/* ── Reset / Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: #F1F5F9;
  color: #1E293B;
}

/* ── Layout ───────────────────────────────────────────────── */
.app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  background: #1E293B;
  color: #F8FAFC;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
}

.header-left  { display: flex; align-items: center; gap: 16px; }
.header-right { flex-shrink: 0; }

.app-title {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.last-synced {
  font-size: 12px;
  color: #94A3B8;
  white-space: nowrap;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  box-sizing: border-box;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary  { background: #3B82F6; color: #fff; border-color: #2563EB; }
.btn-primary:hover:not(:disabled) { background: #2563EB; }

.btn-secondary { background: #fff; color: #374151; border-color: #D1D5DB; }
.btn-secondary:hover:not(:disabled) { background: #F9FAFB; border-color: #9CA3AF; }

.btn-ghost    { background: transparent; color: #475569; border-color: #CBD5E1; }
.btn-ghost:hover:not(:disabled) { background: #F1F5F9; }

.btn-icon { font-size: 16px; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 64px;
  right: 24px;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  transition: opacity 0.3s;
}
.toast--success { background: #D1FAE5; color: #065F46; }
.toast--error   { background: #FEE2E2; color: #991B1B; }
.toast--info    { background: #DBEAFE; color: #1E40AF; }
.hidden         { display: none !important; }

/* ── Tab navigation ───────────────────────────────────────── */
.tab-nav {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #E2E8F0;
  padding: 0 24px;
  gap: 0;
  flex-shrink: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: #64748B;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover  { color: #1E293B; }
.tab-btn.active { color: #3B82F6; border-bottom-color: #3B82F6; }

/* ── Shared team filter bar ────────────────────────────────── */
.shared-filter-wrap {
  padding: 10px 24px;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Main content area ────────────────────────────────────── */
.app-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0; /* 讓 flex child 不超出父容器 */
}

.tab-pane {
  padding: 24px;
  overflow-y: auto;
  height: 100%;
  box-sizing: border-box;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  font-size: 14px;
  color: #64748B;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid #E2E8F0;
  border-top-color: #3B82F6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pane header ──────────────────────────────────────────── */
.pane-header { margin-bottom: 20px; }
.pane-header h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.pane-header--row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.pane-description { color: #64748B; font-size: 13px; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: #94A3B8;
  font-size: 15px;
  line-height: 2;
}

/* ── Hierarchical team filter (dept-tree pattern) ─────────── */
.dept-tree-wrap {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.dept-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .4rem;
  padding: 0 12px;
  height: 34px;
  background: #fff;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #1E293B;
  cursor: pointer;
  white-space: nowrap;
  min-width: 180px;
  transition: border-color .15s, box-shadow .15s;
  text-align: left;
}
.dept-trigger--open,
.dept-trigger:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}

.dept-arrow { font-size: .6rem; opacity: .65; flex-shrink: 0; }

.dept-popup {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  min-width: 280px;
  max-width: 400px;
  max-height: 440px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: .4rem 0 .5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.dept-popup-head {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .55rem .45rem;
  border-bottom: 1px solid #F1F5F9;
  margin-bottom: .3rem;
}

.dept-clear-btn {
  background: none;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
  color: #64748B;
  font-size: .7rem;
  padding: .18rem .55rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.dept-clear-btn:hover { color: #1E293B; border-color: #3B82F6; }

.dept-filter-input {
  flex: 1;
  min-width: 0;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
  color: #1E293B;
  font-size: .74rem;
  padding: .2rem .45rem;
  outline: none;
}
.dept-filter-input:focus { border-color: #3B82F6; }

.dept-tree-list,
.dept-children {
  list-style: none;
  margin: 0;
  padding: 0;
}
.dept-children { padding-left: 1.3rem; }

.dept-node { display: block; }

/* Empty (zero-member) dept: grayed out, checkbox not interactive */
.dept-node--empty > .dept-row .dept-name { opacity: 0.4; }
.dept-node--empty > .dept-row input[type="checkbox"] { cursor: not-allowed; }

.dept-row {
  display: flex;
  align-items: center;
}

/* Group node row */
.dept-node.dept-group > .dept-row {
  background: #F8FAFC;
  border-bottom: 1px solid #F1F5F9;
}

.dept-toggle {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0; margin: 0;
  color: #94A3B8;
  font-size: .62rem;
  width: 16px; min-width: 16px;
  line-height: 1;
  cursor: pointer;
  text-align: center;
  transition: color .12s;
}
.dept-toggle:hover { color: #475569; }

.dept-toggle-spacer {
  flex-shrink: 0;
  display: inline-block;
  width: 16px; min-width: 16px;
}

.dept-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex: 1;
  padding: .28rem .6rem .28rem .15rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background .1s;
  min-width: 0;
}
.dept-label:hover { background: rgba(59,130,246,.07); }

.dept-cb {
  flex-shrink: 0;
  accent-color: #3B82F6;
  width: .85em; height: .85em;
  cursor: pointer;
}

.dept-name {
  font-size: 12px;
  color: #334155;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dept-node.dept-group > .dept-row .dept-name {
  font-weight: 600;
  font-size: 13px;
  color: #1E293B;
}

.fd-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fd-cnt {
  font-size: 11px;
  color: #94A3B8;
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 8px;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: #3B82F6;
  cursor: pointer;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

.filter-sep { color: #CBD5E1; font-size: 12px; }

/* ── Release Package filter ──────────────────────────────────── */
.rp-wrap {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}
.rp-list {
  list-style: none;
  margin: 0;
  padding: .3rem 0;
}
.rp-item { display: block; }
.rp-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .28rem .75rem;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  border-radius: 4px;
  transition: background .1s;
  white-space: nowrap;
}
.rp-label:hover { background: rgba(59,130,246,.07); }
.rp-label input { accent-color: #3B82F6; flex-shrink: 0; }
.text-right { text-align: right; }
.muted      { color: #94A3B8; }
.p-sm       { padding: 14px 18px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-danger { background: #FEE2E2; color: #991B1B; }
/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #E2E8F0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #94A3B8;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: #F1F5F9; color: #475569; }

.modal-body    { padding: 16px 20px; }
.modal-context { font-size: 12px; color: #64748B; margin-bottom: 10px; }

.modal-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}
.modal-textarea:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59,130,246,.2);
}

.modal-char-count { text-align: right; font-size: 11px; color: #94A3B8; margin-top: 4px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #E2E8F0;
  background: #F8FAFC;
}
