* { box-sizing: border-box; }

body.pf-body {
  margin: 0;
  font-family: var(--pf-font);
  background: var(--pf-bg-app);
  color: var(--pf-text-primary);
}

.hidden { display: none !important; }

.pf-layout {
  display: flex;
  min-height: 100dvh;
}

.pf-sidebar {
  width: var(--pf-sidebar-width);
  flex-shrink: 0;
  background: var(--pf-bg-nav);
  background-color: var(--pf-bg-nav-solid);
  color: var(--pf-text-inverse);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.pf-sidebar-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 12px;
}

.pf-brand-link {
  display: block;
  line-height: 0;
  text-decoration: none;
}

.pf-brand-logo {
  display: block;
  width: min(100%, 200px);
  height: auto;
  max-height: 52px;
  object-fit: contain;
  object-position: left center;
}

.pf-brand-tagline {
  display: block;
  padding: 0 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
  line-height: 1.35;
}

.pf-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.pf-sidebar-brand strong { display: block; font-size: 1rem; }
.pf-sidebar-brand small { color: rgba(255, 255, 255, 0.72); font-size: 0.72rem; }

.pf-nav { flex: 1; display: flex; flex-direction: column; gap: 16px; }

.pf-nav-group-label {
  margin: 0 8px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.pf-nav-group-links { display: flex; flex-direction: column; gap: 2px; }

.pf-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--pf-radius-sm);
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.pf-nav-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.pf-nav-link.is-active {
  background: rgba(220, 38, 38, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brand-accent);
}

.pf-nav-icon {
  width: 20px;
  text-align: center;
  opacity: 0.95;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.pf-nav-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--brand-accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
}

.pf-nav-tag {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pf-sidebar-foot {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pf-branch-label { display: block; font-size: 0.72rem; color: rgba(255, 255, 255, 0.55); margin-bottom: 6px; }
.pf-select {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--pf-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: inherit;
}

.pf-sidebar-help {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--pf-radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
}

.pf-sidebar-help p { margin: 0 0 4px; font-weight: 600; color: #fff; }
.pf-sidebar-help small { color: rgba(255, 255, 255, 0.62); }

.pf-main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.pf-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--pf-bg-surface);
  border-bottom: 1px solid var(--pf-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.pf-topbar--compact {
  justify-content: space-between;
}

.pf-topbar--compact .pf-topbar-actions {
  margin-left: auto;
}

.pf-topbar-search-wrap { flex: 1; max-width: 560px; }

.pf-topbar-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--pf-border);
  border-radius: 999px;
  background: var(--pf-bg-muted);
  font: inherit;
}

.pf-topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.pf-system-mode-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pf-system-mode-pill--shadow {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.pf-system-mode-pill--live {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.pf-system-mode-pill.hidden { display: none; }

.pf-content {
  flex: 1;
  padding: 20px;
  min-width: 0;
}

.pf-icon-btn, .pf-btn {
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: var(--pf-radius-sm);
}

.pf-btn-ghost-sm {
  padding: 8px 12px;
  background: transparent;
  color: var(--pf-text-secondary);
  border: 1px solid var(--pf-border);
}

.pf-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  font-size: 1.2rem;
  padding: 8px;
  color: var(--pf-text-primary);
}

body.pf-sidebar-collapsed .pf-sidebar {
  width: 0;
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: width 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
}

.pf-sidebar {
  transition: width 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
}

.pf-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  right: auto;
  transform: translateX(-50%) translateY(120%);
  z-index: 2400;
  min-width: min(320px, calc(100vw - 32px));
  max-width: min(520px, calc(100vw - 32px));
  padding: 14px 20px;
  border-radius: 12px;
  background: #0f766e;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pf-toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.pf-toast--ok { background: #15803d; }
.pf-toast--error { background: #b91c1c; }
.pf-toast--info { background: #1d4ed8; }

.pf-progress {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
}

.pf-progress[hidden] {
  display: none !important;
}

.pf-progress-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  padding: 18px 20px 16px;
}

.pf-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.pf-progress-head strong {
  font-size: 0.98rem;
  color: #0f172a;
}

.pf-progress-elapsed {
  font-size: 0.76rem;
  font-weight: 700;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.pf-progress-bar-track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-bottom: 12px;
}

.pf-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ef4444, #dc2626);
  transition: width 0.35s ease;
}

.pf-progress.is-indeterminate .pf-progress-bar {
  width: 36% !important;
  animation: pf-progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes pf-progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.pf-progress-message {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #991b1b;
}

.pf-progress-detail {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: #64748b;
  min-height: 1.1em;
}

.pf-progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.pf-progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: #94a3b8;
}

.pf-progress-step.is-current {
  color: #dc2626;
  font-weight: 700;
}

.pf-progress-step.is-done {
  color: #047857;
}

.pf-progress-step-mark {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.pf-progress.is-success .pf-progress-bar {
  background: linear-gradient(90deg, #10b981, #059669);
}

.pf-progress.is-error .pf-progress-bar {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

body.pf-body--ops-minimal .pf-sidebar { width: 200px; }
body.pf-body--ops-minimal .pf-nav-group-label,
body.pf-body--ops-minimal .pf-sidebar-help,
body.pf-body--ops-minimal .pf-sidebar-foot { display: none; }
body.pf-body--ops-minimal .pf-topbar-search-wrap { display: none; }

.pf-nav-close,
.pf-nav-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .pf-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.15rem;
    line-height: 1;
  }

  .pf-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  body.pf-nav-open .pf-nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.pf-nav-open {
    overflow: hidden;
  }

  body.pf-sidebar-collapsed .pf-sidebar {
    width: var(--pf-sidebar-width);
    min-width: auto;
    padding: 16px 12px;
    opacity: 1;
    pointer-events: auto;
  }

  .pf-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  body.pf-nav-open .pf-sidebar {
    transform: translateX(0);
    width: var(--pf-sidebar-width);
    min-width: auto;
    padding: 16px 12px;
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 768px) {
  .pf-content { padding: 12px; }

  .pf-topbar--compact {
    padding: 10px 12px;
    gap: 8px;
  }
}
